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

Method Skip

msgp/read.go:377–424  ·  view source on GitHub ↗

Skip skips over the next object, regardless of its type. If it is an array or map, the whole array or map will be skipped.

()

Source from the content-addressed store, hash-verified

375// its type. If it is an array or map, the whole array
376// or map will be skipped.
377func (m *Reader) Skip() error {
378 var (
379 v uintptr // bytes
380 o uintptr // objects
381 err error
382 p []byte
383 )
384
385 // we can use the faster
386 // method if we have enough
387 // buffered data
388 if m.R.Buffered() >= 5 {
389 p, err = m.R.Peek(5)
390 if err != nil {
391 return err
392 }
393 v, o, err = getSize(p)
394 if err != nil {
395 return err
396 }
397 } else {
398 v, o, err = getNextSize(m.R)
399 if err != nil {
400 return err
401 }
402 }
403
404 // 'v' is always non-zero
405 // if err == nil
406 _, err = m.R.Skip(int(v))
407 if err != nil {
408 return err
409 }
410
411 // for maps and slices, skip elements with recursive call
412 if done, err := m.recursiveCall(); err != nil {
413 return err
414 } else {
415 defer done()
416 }
417 for x := uintptr(0); x < o; x++ {
418 err = m.Skip()
419 if err != nil {
420 return err
421 }
422 }
423 return nil
424}
425
426// ReadMapHeader reads the next object
427// as a map header and returns the size

Callers 15

TestSkipRecursionFunction · 0.95
TestSkipFunction · 0.95
BenchmarkSkipFunction · 0.95
FuzzReaderFunction · 0.95
ReadExtensionMethod · 0.80
ReadMapHeaderMethod · 0.80
ReadMapKeyPtrMethod · 0.80
ReadArrayHeaderMethod · 0.80
ReadNilMethod · 0.80
ReadFloat64Method · 0.80
ReadFloat32Method · 0.80
ReadBoolMethod · 0.80

Calls 4

recursiveCallMethod · 0.95
getSizeFunction · 0.85
getNextSizeFunction · 0.85
BufferedMethod · 0.45

Tested by 4

TestSkipRecursionFunction · 0.76
TestSkipFunction · 0.76
BenchmarkSkipFunction · 0.76
FuzzReaderFunction · 0.76