@@ -39,22 +39,24 @@ var FileReaderPool = sync.Pool{
39
39
// ByteBufferPool is a pool for temporary byte slices
40
40
var ByteBufferPool = sync.Pool {
41
41
New : func () interface {} {
42
- // 8KB initial capacity is a good balance
43
- return make ([] byte , 0 , 8 * 1024 )
42
+ slice := make ([] byte , 0 , 8 * 1024 )
43
+ return & slice
44
44
},
45
45
}
46
46
47
47
// StringBufferPool is a pool for string slices
48
48
var StringBufferPool = sync.Pool {
49
49
New : func () interface {} {
50
- return make ([]string , 0 , 32 )
50
+ slice := make ([]string , 0 , 32 )
51
+ return & slice
51
52
},
52
53
}
53
54
54
55
// ExtendedPosPool is a pool for slices of ExtendedPos
55
56
var ExtendedPosPool = sync.Pool {
56
57
New : func () interface {} {
57
- return make ([]ExtendedPos , 0 , 8 )
58
+ slice := make ([]ExtendedPos , 0 , 8 )
59
+ return & slice
58
60
},
59
61
}
60
62
@@ -90,7 +92,7 @@ func PutStringBuilder(sb *strings.Builder) {
90
92
91
93
// GetByteBuffer retrieves a byte buffer from the pool
92
94
func GetByteBuffer () []byte {
93
- return ByteBufferPool .Get ().([]byte )[:0 ] // Reset length but keep capacity
95
+ return ( * ByteBufferPool .Get ().(* []byte ) )[:0 ] // Reset length but keep capacity
94
96
}
95
97
96
98
// PutByteBuffer returns a byte buffer to the pool
@@ -101,18 +103,18 @@ func PutByteBuffer(buf []byte) {
101
103
102
104
// GetStringBuffer retrieves a string slice from the pool
103
105
func GetStringBuffer () []string {
104
- return StringBufferPool .Get ().([]string )[:0 ] // Reset length but keep capacity
106
+ return ( * StringBufferPool .Get ().(* []string ) )[:0 ] // Reset length but keep capacity
105
107
}
106
108
107
109
// PutStringBuffer returns a string slice to the pool
108
110
func PutStringBuffer (slice []string ) {
109
111
sliceCopy := make ([]string , 0 , cap (slice ))
110
- StringBufferPool .Put (sliceCopy )
112
+ StringBufferPool .Put (& sliceCopy )
111
113
}
112
114
113
115
// GetExtendedPosBuffer retrieves an ExtendedPos slice from the pool
114
116
func GetExtendedPosBuffer () []ExtendedPos {
115
- return ExtendedPosPool .Get ().([]ExtendedPos )[:0 ] // Reset length but keep capacity
117
+ return ( * ExtendedPosPool .Get ().(* []ExtendedPos ) )[:0 ] // Reset length but keep capacity
116
118
}
117
119
118
120
// PutExtendedPosBuffer returns an ExtendedPos slice to the pool
0 commit comments