MCPcopy
hub / github.com/TarsCloud/TarsGo / SkipToNoCheck

Method SkipToNoCheck

tars/protocol/codec/codec.go:535–562  ·  view source on GitHub ↗

SkipToNoCheck for skip to the none StructEnd tag.

(tag byte, require bool)

Source from the content-addressed store, hash-verified

533
534// SkipToNoCheck for skip to the none StructEnd tag.
535func (b *Reader) SkipToNoCheck(tag byte, require bool) (bool, byte, error) {
536 for {
537 tyCur, tagCur, err := b.readHead()
538 if err != nil {
539 if require {
540 return false, tyCur, fmt.Errorf("can not find Tag %d. But require. %s", tag, err.Error())
541 }
542 return false, tyCur, nil
543 }
544 if tyCur == StructEnd || tagCur > tag {
545 if require {
546 return false, tyCur, fmt.Errorf("can not find Tag %d. But require. tagCur: %d, tyCur: %d",
547 tag, tagCur, tyCur)
548 }
549 // 多读了一个head, 退回去.
550 b.unreadHead(tagCur)
551 return false, tyCur, nil
552 }
553 if tagCur == tag {
554 return true, tyCur, nil
555 }
556
557 // tagCur < tag
558 if err = b.skipField(tyCur); err != nil {
559 return false, tyCur, err
560 }
561 }
562}
563
564// SkipTo skip to the given tag.
565func (b *Reader) SkipTo(ty, tag byte, require bool) (bool, error) {

Callers 15

SkipToMethod · 0.95
ReadInt8Method · 0.95
ReadInt16Method · 0.95
ReadInt32Method · 0.95
ReadInt64Method · 0.95
ReadFloat32Method · 0.95
ReadFloat64Method · 0.95
ReadStringMethod · 0.95
GetTokensWithContextMethod · 0.95
DispatchMethod · 0.95
DispatchMethod · 0.95
ListConfigWithContextMethod · 0.95

Calls 5

readHeadMethod · 0.95
unreadHeadMethod · 0.95
skipFieldMethod · 0.95
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by 1

TestReader_SkipToNoCheckFunction · 0.64