diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-08-05 10:20:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-05 10:20:38 +0100 |
commit | e6f68d2e4cd1bc4447126816c7c27e1fc2098e30 (patch) | |
tree | 15c5e333b93641f9eadcb4bf4b34c338135f7a23 /plumbing/format/packfile/diff_delta.go | |
parent | 5882d60fb7ccd4cfc0fe69286aa96e198c9d1eb0 (diff) | |
parent | 4ec6b3f4fa9cdfe8f10d0953ac7d398d01a90f17 (diff) | |
download | go-git-e6f68d2e4cd1bc4447126816c7c27e1fc2098e30.tar.gz |
Merge branch 'master' into jc/commit-ammend
Diffstat (limited to 'plumbing/format/packfile/diff_delta.go')
-rw-r--r-- | plumbing/format/packfile/diff_delta.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/plumbing/format/packfile/diff_delta.go b/plumbing/format/packfile/diff_delta.go index 1951b34..2c7a335 100644 --- a/plumbing/format/packfile/diff_delta.go +++ b/plumbing/format/packfile/diff_delta.go @@ -5,6 +5,7 @@ import ( "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/utils/ioutil" + "github.com/go-git/go-git/v5/utils/sync" ) // See https://github.com/jelmer/dulwich/blob/master/dulwich/pack.py and @@ -43,18 +44,16 @@ func getDelta(index *deltaIndex, base, target plumbing.EncodedObject) (o plumbin defer ioutil.CheckClose(tr, &err) - bb := bufPool.Get().(*bytes.Buffer) - defer bufPool.Put(bb) - bb.Reset() + bb := sync.GetBytesBuffer() + defer sync.PutBytesBuffer(bb) _, err = bb.ReadFrom(br) if err != nil { return nil, err } - tb := bufPool.Get().(*bytes.Buffer) - defer bufPool.Put(tb) - tb.Reset() + tb := sync.GetBytesBuffer() + defer sync.PutBytesBuffer(tb) _, err = tb.ReadFrom(tr) if err != nil { @@ -80,9 +79,8 @@ func DiffDelta(src, tgt []byte) []byte { } func diffDelta(index *deltaIndex, src []byte, tgt []byte) []byte { - buf := bufPool.Get().(*bytes.Buffer) - defer bufPool.Put(buf) - buf.Reset() + buf := sync.GetBytesBuffer() + defer sync.PutBytesBuffer(buf) buf.Write(deltaEncodeSize(len(src))) buf.Write(deltaEncodeSize(len(tgt))) @@ -90,9 +88,8 @@ func diffDelta(index *deltaIndex, src []byte, tgt []byte) []byte { index.init(src) } - ibuf := bufPool.Get().(*bytes.Buffer) - defer bufPool.Put(ibuf) - ibuf.Reset() + ibuf := sync.GetBytesBuffer() + defer sync.PutBytesBuffer(ibuf) for i := 0; i < len(tgt); i++ { offset, l := index.findMatch(src, tgt, i) |