MCPcopy Index your code
hub / github.com/tinylib/msgp / Replace

Function Replace

msgp/edit.go:23–29  ·  view source on GitHub ↗

Replace takes a key ("key") in a messagepack map ("raw") and replaces its value with the one provided and returns the new []byte. The returned []byte may point to the same memory as "raw". Replace makes no effort to evaluate the validity of the contents of 'val'. It may use up to the full capacity o

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

Source from the content-addressed store, hash-verified

21// Replace returns 'nil' if the field doesn't exist or if the object in 'raw'
22// is not a map.
23func Replace(key string, raw []byte, val []byte) []byte {
24 start, end := locate(raw, key)
25 if start == end {
26 return nil
27 }
28 return replace(raw, start, end, val, true)
29}
30
31// CopyReplace works similarly to Replace except that the returned
32// byte slice does not point to the same memory as 'raw'. CopyReplace

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…