Skip to content

Commit

Permalink
chore: add more common for UnsafeLinkBuffer Peek
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost committed Jun 6, 2024
1 parent ee8ff3e commit 0ebdfd6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nocopy_linkbuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ func (b *UnsafeLinkBuffer) Peek(n int) (p []byte, err error) {
}
p = b.cachePeek
if len(p) >= n {
// in case we peek smaller than last time
// we will reset cachePeek when Next or Skip
// in case we peek smaller than last time,
// we can return cache data directly.
// we will reset cachePeek when Next or Skip, no worries about stale data
return p[:n], nil
}

Expand Down

0 comments on commit 0ebdfd6

Please sign in to comment.