We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ba9f557 + 7d8f420 commit 5f6d4feCopy full SHA for 5f6d4fe
1 file changed
decode.go
@@ -624,6 +624,11 @@ func (d *Decoder) ReadFull(buf []byte) error {
624
}
625
626
func (d *Decoder) hasNilCode() bool {
627
+ // Fast path: when decoding from a byte slice, peek directly
628
+ // to avoid two interface method calls (ReadByte + UnreadByte).
629
+ if d.s == &d.bsr {
630
+ return d.bsr.pos < len(d.bsr.data) && d.bsr.data[d.bsr.pos] == msgpcode.Nil
631
+ }
632
code, err := d.PeekCode()
633
return err == nil && code == msgpcode.Nil
634
0 commit comments