aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile
diff options
context:
space:
mode:
authorNao YONASHIRO <owan.orisano@gmail.com>2019-06-29 02:04:09 +0900
committerNao YONASHIRO <owan.orisano@gmail.com>2019-07-31 00:23:33 +0900
commitc1086eafdf45fe85ce0050890da6b42a146c7ddc (patch)
treed653ac8cb11186dc7e50e2ffc8a4ac572004992f /plumbing/format/packfile
parentf2fd9299c7529ad22c05e9d17dc3ceadcf22490c (diff)
downloadgo-git-c1086eafdf45fe85ce0050890da6b42a146c7ddc.tar.gz
refactor: use bufPool
Signed-off-by: Nao YONASHIRO <owan.orisano@gmail.com>
Diffstat (limited to 'plumbing/format/packfile')
-rw-r--r--plumbing/format/packfile/patch_delta.go15
1 files changed, 3 insertions, 12 deletions
diff --git a/plumbing/format/packfile/patch_delta.go b/plumbing/format/packfile/patch_delta.go
index 45e589e..7840f17 100644
--- a/plumbing/format/packfile/patch_delta.go
+++ b/plumbing/format/packfile/patch_delta.go
@@ -3,7 +3,6 @@ package packfile
import (
"bytes"
"errors"
- "sync"
"gopkg.in/src-d/go-git.v4/plumbing"
)
@@ -15,12 +14,6 @@ import (
const deltaSizeMin = 4
-var bytesBufferPool = sync.Pool{
- New: func() interface{} {
- return &bytes.Buffer{}
- },
-}
-
// ApplyDelta writes to target the result of applying the modification deltas in delta to base.
func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) error {
r, err := base.Reader()
@@ -33,11 +26,9 @@ func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) error {
return err
}
- buf := bytesBufferPool.Get().(*bytes.Buffer)
- defer func() {
- buf.Reset()
- bytesBufferPool.Put(buf)
- } ()
+ buf := bufPool.Get().(*bytes.Buffer)
+ defer bufPool.Put(buf)
+ buf.Reset()
_, err = buf.ReadFrom(r)
if err != nil {
return err