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

Method ReadMapHeader

msgp/read.go:431–462  ·  view source on GitHub ↗

ReadMapHeader reads the next object as a map header and returns the size of the map and the number of bytes written. It will return a TypeError{} if the next object is not a map.

()

Source from the content-addressed store, hash-verified

429// It will return a TypeError{} if the next
430// object is not a map.
431func (m *Reader) ReadMapHeader() (sz uint32, err error) {
432 var p []byte
433 var lead byte
434 lead, err = m.R.PeekByte()
435 if err != nil {
436 return
437 }
438 if isfixmap(lead) {
439 sz = uint32(rfixmap(lead))
440 _, err = m.R.Skip(1)
441 return
442 }
443 switch lead {
444 case mmap16:
445 p, err = m.R.Next(3)
446 if err != nil {
447 return
448 }
449 sz = uint32(big.Uint16(p[1:]))
450 return
451 case mmap32:
452 p, err = m.R.Next(5)
453 if err != nil {
454 return
455 }
456 sz = big.Uint32(p[1:])
457 return
458 default:
459 err = badPrefix(MapType, lead)
460 return
461 }
462}
463
464// ReadMapKey reads either a 'str' or 'bin' field from
465// the reader and returns the value as a []byte. It uses

Callers 7

TestReadMapHeaderFunction · 0.95
BenchmarkReadMapHeaderFunction · 0.95
FuzzReaderFunction · 0.95
ReadMapStrIntfMethod · 0.95
checkExtMinusOneFunction · 0.95
rwMapFunction · 0.80
ReadMapFunction · 0.80

Calls 4

isfixmapFunction · 0.85
rfixmapFunction · 0.85
badPrefixFunction · 0.85
SkipMethod · 0.80

Tested by 4

TestReadMapHeaderFunction · 0.76
BenchmarkReadMapHeaderFunction · 0.76
FuzzReaderFunction · 0.76
checkExtMinusOneFunction · 0.76