Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 641f4f5

Browse files
internal/bpool: add New function (#465)
Signed-off-by: bestgopher <84328409@qq.com>
1 parent 4ce1d90 commit 641f4f5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎internal/bpool/bpool.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import (
55
"sync"
66
)
77

8-
var bpool sync.Pool
8+
var bpool = sync.Pool{
9+
New: func() any {
10+
return &bytes.Buffer{}
11+
},
12+
}
913

1014
// Get returns a buffer from the pool or creates a new one if
1115
// the pool is empty.
1216
func Get() *bytes.Buffer {
1317
b := bpool.Get()
14-
if b == nil {
15-
return &bytes.Buffer{}
16-
}
1718
return b.(*bytes.Buffer)
1819
}
1920

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /