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

Function getNextSize

msgp/read.go:337–372  ·  view source on GitHub ↗

getNextSize returns the size of the next object on the wire. returns (obj size, obj elements, error) only maps and arrays have non-zero obj elements for maps and arrays, obj size does not include elements use uintptr b/c it's guaranteed to be large enough to hold whatever we can fit in memory.

(r *fwd.Reader)

Source from the content-addressed store, hash-verified

335// use uintptr b/c it's guaranteed to be large enough
336// to hold whatever we can fit in memory.
337func getNextSize(r *fwd.Reader) (uintptr, uintptr, error) {
338 lead, err := r.PeekByte()
339 if err != nil {
340 return 0, 0, err
341 }
342 spec := getBytespec(lead)
343 size, mode := spec.size, spec.extra
344 if size == 0 {
345 return 0, 0, InvalidPrefixError(lead)
346 }
347 if mode >= 0 {
348 return uintptr(size), uintptr(mode), nil
349 }
350 b, err := r.Peek(int(size))
351 if err != nil {
352 return 0, 0, err
353 }
354 switch mode {
355 case extra8:
356 return uintptr(size) + uintptr(b[1]), 0, nil
357 case extra16:
358 return uintptr(size) + uintptr(big.Uint16(b[1:])), 0, nil
359 case extra32:
360 return uintptr(size) + uintptr(big.Uint32(b[1:])), 0, nil
361 case map16v:
362 return uintptr(size), 2 * uintptr(big.Uint16(b[1:])), nil
363 case map32v:
364 return uintptr(size), 2 * uintptr(big.Uint32(b[1:])), nil
365 case array16v:
366 return uintptr(size), uintptr(big.Uint16(b[1:])), nil
367 case array32v:
368 return uintptr(size), uintptr(big.Uint32(b[1:])), nil
369 default:
370 return 0, 0, fatal
371 }
372}
373
374// Skip skips over the next object, regardless of
375// its type. If it is an array or map, the whole array

Callers 3

CopyNextMethod · 0.85
SkipMethod · 0.85
appendNextFunction · 0.85

Calls 2

InvalidPrefixErrorTypeAlias · 0.85
getBytespecFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…