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

Function HasKey

msgp/edit.go:55–71  ·  view source on GitHub ↗

HasKey returns whether the map in 'raw' has a field with key 'key'

(key string, raw []byte)

Source from the content-addressed store, hash-verified

53// HasKey returns whether the map in 'raw' has
54// a field with key 'key'
55func HasKey(key string, raw []byte) bool {
56 sz, bts, err := ReadMapHeaderBytes(raw)
57 if err != nil {
58 return false
59 }
60 var field []byte
61 for range sz {
62 field, bts, err = ReadStringZC(bts)
63 if err != nil {
64 return false
65 }
66 if UnsafeString(field) == key {
67 return true
68 }
69 }
70 return false
71}
72
73func replace(raw []byte, start int, end int, val []byte, inplace bool) []byte {
74 ll := end - start // length of segment to replace

Callers 1

TestLocateFunction · 0.85

Calls 3

ReadMapHeaderBytesFunction · 0.85
ReadStringZCFunction · 0.85
UnsafeStringFunction · 0.70

Tested by 1

TestLocateFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…