Skip to content

Commit

Permalink
Fixing sizing issue
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Vij <[email protected]>
  • Loading branch information
ShivanshVij committed Oct 12, 2023
1 parent 145beac commit ff0fe6e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func (buf *Buffer) Reset() {
func (buf *Buffer) Grow(n int) {
if cap(buf.b)-buf.offset < n {
if cap(buf.b) < n {
buf.b = append(buf.b[:buf.offset], make([]byte, n)...)
buf.b = append(buf.b[:buf.offset], make([]byte, n+cap(buf.b)-buf.offset)...)
} else {
buf.b = append(buf.b[:buf.offset], make([]byte, cap(buf.b))...)
buf.b = append(buf.b[:buf.offset], make([]byte, cap(buf.b)*2-buf.offset)...)
}
}
}
Expand Down

0 comments on commit ff0fe6e

Please sign in to comment.