File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,9 @@ func (sp *byteSlicePools) getSlice(size int) *[]byte {
5252func (sp * byteSlicePools ) reuseSlice (s * []byte ) {
5353 index := int (math .Floor (math .Log2 (float64 (cap (* s ))))) - minPoolSizePower
5454
55- if index >= len (sp .pools ) {
55+ if index >= len (sp .pools ) || index < 0 {
5656 return
5757 }
5858
59- if index < 0 {
60- index = 0
61- }
62-
6359 sp .pools [index ].Put (s )
6460}
Original file line number Diff line number Diff line change @@ -19,3 +19,12 @@ func TestFuzzyByteSlicePools(t *testing.T) {
1919 sut .reuseSlice (s )
2020 }
2121}
22+
23+ func TestReturnSliceSmallerThanMin (t * testing.T ) {
24+ sut := newSlicePool (20 )
25+ size := 3
26+ buff := make ([]byte , 0 , size )
27+ sut .reuseSlice (& buff )
28+ buff2 := sut .getSlice (size * 2 )
29+ assert .Equal (t , len (* buff2 ), size * 2 )
30+ }
Original file line number Diff line number Diff line change @@ -98,7 +98,9 @@ func ReuseWriteRequest(req *PreallocWriteRequest) {
9898 bytePool .reuseSlice (req .data )
9999 req .data = nil
100100 }
101-
101+ req .Source = 0
102+ req .Metadata = nil
103+ req .Timeseries = nil
102104 writeRequestPool .Put (req )
103105}
104106
You can’t perform that action at this time.
0 commit comments