MCPcopy
hub / github.com/tidwall/gjson / fillIndex

Function fillIndex

gjson.go:3349–3358  ·  view source on GitHub ↗

fillIndex finds the position of Raw data and assigns it to the Index field of the resulting value. If the position cannot be found then Index zero is used instead.

(json string, c *parseContext)

Source from the content-addressed store, hash-verified

3347// of the resulting value. If the position cannot be found then Index zero is
3348// used instead.
3349func fillIndex(json string, c *parseContext) {
3350 if len(c.value.Raw) > 0 && !c.calcd {
3351 jhdr := *(*stringHeader)(unsafe.Pointer(&json))
3352 rhdr := *(*stringHeader)(unsafe.Pointer(&(c.value.Raw)))
3353 c.value.Index = int(uintptr(rhdr.data) - uintptr(jhdr.data))
3354 if c.value.Index < 0 || c.value.Index >= len(json) {
3355 c.value.Index = 0
3356 }
3357 }
3358}
3359
3360func stringBytes(s string) []byte {
3361 return *(*[]byte)(unsafe.Pointer(&sliceHeader{

Callers 3

parseArrayFunction · 0.85
GetFunction · 0.85
parseAnyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…