Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit c1086ea

Browse files
committed
refactor: use bufPool
Signed-off-by: Nao YONASHIRO <owan.orisano@gmail.com>
1 parent f2fd929 commit c1086ea

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

plumbing/format/packfile/patch_delta.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package packfile
33
import (
44
"bytes"
55
"errors"
6-
"sync"
76

87
"gopkg.in/src-d/go-git.v4/plumbing"
98
)
@@ -15,12 +14,6 @@ import (
1514

1615
const deltaSizeMin = 4
1716

18-
var bytesBufferPool = sync.Pool{
19-
New: func() interface{} {
20-
return &bytes.Buffer{}
21-
},
22-
}
23-
2417
// ApplyDelta writes to target the result of applying the modification deltas in delta to base.
2518
func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) error {
2619
r, err := base.Reader()
@@ -33,11 +26,9 @@ func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) error {
3326
return err
3427
}
3528

36-
buf := bytesBufferPool.Get().(*bytes.Buffer)
37-
defer func() {
38-
buf.Reset()
39-
bytesBufferPool.Put(buf)
40-
} ()
29+
buf := bufPool.Get().(*bytes.Buffer)
30+
defer bufPool.Put(buf)
31+
buf.Reset()
4132
_, err = buf.ReadFrom(r)
4233
if err != nil {
4334
return err

0 commit comments

Comments
 (0)