File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ const (
1313 Size = 8192
1414)
1515
16+ var empty = [Size * 10 ]byte {0 }
17+
1618var pool = bytespool .GetPool (Size )
1719
1820// ownership represents the data owner of the buffer.
@@ -150,6 +152,7 @@ func (b *Buffer) Extend(n int32) []byte {
150152 }
151153 ext := b .v [b .end :end ]
152154 b .end = end
155+ copy (ext , empty [:])
153156 return ext
154157}
155158
@@ -198,6 +201,7 @@ func (b *Buffer) Check() {
198201
199202// Resize cuts the buffer at the given position.
200203func (b * Buffer ) Resize (from , to int32 ) {
204+ oldEnd := b .end
201205 if from < 0 {
202206 from += b .Len ()
203207 }
@@ -210,6 +214,9 @@ func (b *Buffer) Resize(from, to int32) {
210214 b .end = b .start + to
211215 b .start += from
212216 b .Check ()
217+ if b .end > oldEnd {
218+ copy (b .v [oldEnd :b .end ], empty [:])
219+ }
213220}
214221
215222// Advance cuts the buffer at the given position.
You can’t perform that action at this time.
0 commit comments