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

Function locateKV

msgp/edit.go:153–186  ·  view source on GitHub ↗

locate key AND value

(raw []byte, key string)

Source from the content-addressed store, hash-verified

151
152// locate key AND value
153func locateKV(raw []byte, key string) (start int, end int) {
154 var (
155 sz uint32
156 bts []byte
157 field []byte
158 err error
159 )
160 sz, bts, err = ReadMapHeaderBytes(raw)
161 if err != nil {
162 return 0, 0
163 }
164
165 for i := uint32(0); i < sz; i++ {
166 tmp := len(bts)
167 field, bts, err = ReadStringZC(bts)
168 if err != nil {
169 return 0, 0
170 }
171 if UnsafeString(field) == key {
172 start = len(raw) - tmp
173 bts, err = Skip(bts)
174 if err != nil {
175 return 0, 0
176 }
177 end = len(raw) - len(bts)
178 return
179 }
180 bts, err = Skip(bts)
181 if err != nil {
182 return 0, 0
183 }
184 }
185 return 0, 0
186}
187
188// delta is delta on map size
189func resizeMap(raw []byte, delta int64) []byte {

Callers 1

RemoveFunction · 0.85

Calls 4

ReadMapHeaderBytesFunction · 0.85
ReadStringZCFunction · 0.85
SkipFunction · 0.85
UnsafeStringFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…