File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,12 @@ func (wb *WriteBuffer) WriteTo(w io.Writer) (int64, error) {
41
41
for _ , chunk := range wb .chunks {
42
42
ln , err := w .Write (chunk )
43
43
if err != nil {
44
- wb .Reset ()
44
+ wb .clear ()
45
45
return 0 , err
46
46
}
47
47
size += int64 (ln )
48
48
}
49
- wb .Reset ()
49
+ wb .clear ()
50
50
return size , nil
51
51
}
52
52
@@ -86,7 +86,7 @@ func (wb *WriteBuffer) calcCap(dataSize int) int {
86
86
return max (dataSize , cap (wb .chunks [len (wb .chunks )- 1 ])* 2 )
87
87
}
88
88
89
- func (wb * WriteBuffer ) Reset () {
89
+ func (wb * WriteBuffer ) clear () {
90
90
if len (wb .chunks ) == 0 {
91
91
return
92
92
}
@@ -105,6 +105,13 @@ func (wb *WriteBuffer) Reset() {
105
105
wb .chunks = wb .chunks [:1 ]
106
106
}
107
107
108
+ func (wb * WriteBuffer ) Reset () {
109
+ for _ , chunk := range wb .chunks {
110
+ leakypool .PutBytes (chunk [:0 ])
111
+ }
112
+ wb .chunks = nil
113
+ }
114
+
108
115
func max (a , b int ) int {
109
116
if b > a {
110
117
return b
You can’t perform that action at this time.
0 commit comments