MCPcopy
hub / github.com/tinylib/msgp / CopyReplace

Function CopyReplace

msgp/edit.go:34–40  ·  view source on GitHub ↗

CopyReplace works similarly to Replace except that the returned byte slice does not point to the same memory as 'raw'. CopyReplace returns 'nil' if the field doesn't exist or 'raw' isn't a map.

(key string, raw []byte, val []byte)

Source from the content-addressed store, hash-verified

32// byte slice does not point to the same memory as 'raw'. CopyReplace
33// returns 'nil' if the field doesn't exist or 'raw' isn't a map.
34func CopyReplace(key string, raw []byte, val []byte) []byte {
35 start, end := locate(raw, key)
36 if start == end {
37 return nil
38 }
39 return replace(raw, start, end, val, false)
40}
41
42// Remove removes a key-value pair from 'raw'. It returns
43// 'raw' unchanged if the key didn't exist.

Callers 1

TestReplaceFunction · 0.85

Calls 2

locateFunction · 0.85
replaceFunction · 0.70

Tested by 1

TestReplaceFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…