Skip to content

Commit 5735e12

Browse files
authored
Merge pull request #682 from moredure/patch-1
Stop using channel for memory pooling
2 parents a7332a9 + 90c345c commit 5735e12

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

utils/bytes_buffer_pool.go

+2-14
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,17 @@ var (
1515
return &bytes.Buffer{}
1616
},
1717
}
18-
bytesBufferChan = make(chan *bytes.Buffer, 10)
1918
)
2019

2120
func BytesBufferGet() (data *bytes.Buffer) {
22-
select {
23-
case data = <-bytesBufferChan:
24-
default:
25-
data = bytesBufferPool.Get().(*bytes.Buffer)
26-
}
27-
21+
data = bytesBufferPool.Get().(*bytes.Buffer)
2822
data.Reset()
29-
3023
return data
3124
}
3225

3326
func BytesBufferPut(data *bytes.Buffer) {
3427
if data == nil || len(data.Bytes()) > TooBigBlockSize {
3528
return
3629
}
37-
38-
select {
39-
case bytesBufferChan <- data:
40-
default:
41-
bytesBufferPool.Put(data)
42-
}
30+
bytesBufferPool.Put(data)
4331
}

0 commit comments

Comments
 (0)