File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -27,23 +27,26 @@ import (
27
27
// slicePool is a shared pool of hash slice, for reducing the GC pressure.
28
28
var slicePool = sync.Pool {
29
29
New : func () interface {} {
30
- return make ([]common.Hash , 0 , 64 ) // Pre-allocate a slice with a reasonable capacity.
30
+ slice := make ([]common.Hash , 0 , 16 ) // Pre-allocate a slice with a reasonable capacity.
31
+ return & slice
31
32
},
32
33
}
33
34
34
35
// getSlice obtains the hash slice from the shared pool.
35
36
func getSlice () []common.Hash {
36
- return slicePool .Get ().([]common.Hash )
37
+ slice := * slicePool .Get ().(* []common.Hash )
38
+ slice = slice [:0 ]
39
+ return slice
37
40
}
38
41
39
42
// returnSlice returns the hash slice back to the shared pool for following usage.
40
43
func returnSlice (slice []common.Hash ) {
41
44
// Discard the large slice for recycling
42
- if len (slice ) > 1024 {
45
+ if len (slice ) > 128 {
43
46
return
44
47
}
45
48
// Reset the slice before putting it back into the pool
46
- slicePool .Put (slice [: 0 ] )
49
+ slicePool .Put (& slice )
47
50
}
48
51
49
52
// lookup is an internal help structure to quickly identify
You can’t perform that action at this time.
0 commit comments