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

Method ReadArrayHeader

msgp/read.go:537–569  ·  view source on GitHub ↗

ReadArrayHeader reads the next object as an array header and returns the size of the array and the number of bytes read.

()

Source from the content-addressed store, hash-verified

535// array header and returns the size of the array
536// and the number of bytes read.
537func (m *Reader) ReadArrayHeader() (sz uint32, err error) {
538 lead, err := m.R.PeekByte()
539 if err != nil {
540 return
541 }
542 if isfixarray(lead) {
543 sz = uint32(rfixarray(lead))
544 _, err = m.R.Skip(1)
545 return
546 }
547 var p []byte
548 switch lead {
549 case marray16:
550 p, err = m.R.Next(3)
551 if err != nil {
552 return
553 }
554 sz = uint32(big.Uint16(p[1:]))
555 return
556
557 case marray32:
558 p, err = m.R.Next(5)
559 if err != nil {
560 return
561 }
562 sz = big.Uint32(p[1:])
563 return
564
565 default:
566 err = badPrefix(ArrayType, lead)
567 return
568 }
569}
570
571// ReadNil reads a 'nil' MessagePack byte from the reader
572func (m *Reader) ReadNil() error {

Callers 15

TestReadArrayHeaderFunction · 0.95
BenchmarkReadArrayHeaderFunction · 0.95
FuzzReaderFunction · 0.95
ReadIntfMethod · 0.95
rwArrayFunction · 0.80
ReadArrayFunction · 0.80
DecodeMsgMethod · 0.80
DecodeMsgMethod · 0.80
DecodeMsgMethod · 0.80
DecodeMsgMethod · 0.80
DecodeMsgMethod · 0.80
DecodeMsgMethod · 0.80

Calls 4

isfixarrayFunction · 0.85
rfixarrayFunction · 0.85
badPrefixFunction · 0.85
SkipMethod · 0.80

Tested by 3

TestReadArrayHeaderFunction · 0.76
BenchmarkReadArrayHeaderFunction · 0.76
FuzzReaderFunction · 0.76