aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/decoder.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-09-04 19:43:36 +0200
committerGitHub <noreply@github.com>2017-09-04 19:43:36 +0200
commitf9879dd043f84936a1f8acb8a53b74332a7ae135 (patch)
tree13283ed091249f601ceacd7c64a3467c5f4eac78 /plumbing/format/packfile/decoder.go
parent770800d980ba7e0af40502324d15ed50445a3291 (diff)
parent6a46a7eb543789c7012bf0f964e1b6b38eca150c (diff)
downloadgo-git-f9879dd043f84936a1f8acb8a53b74332a7ae135.tar.gz
Merge pull request #578 from erizocosmico/perf/reduce-gc-pressv4.0.0-rc15
packfile: improve performance a little by reducing gc pressure
Diffstat (limited to 'plumbing/format/packfile/decoder.go')
-rw-r--r--plumbing/format/packfile/decoder.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/plumbing/format/packfile/decoder.go b/plumbing/format/packfile/decoder.go
index e49de51..3d475b2 100644
--- a/plumbing/format/packfile/decoder.go
+++ b/plumbing/format/packfile/decoder.go
@@ -347,7 +347,8 @@ func (d *Decoder) fillRegularObjectContent(obj plumbing.EncodedObject) (uint32,
}
func (d *Decoder) fillREFDeltaObjectContent(obj plumbing.EncodedObject, ref plumbing.Hash) (uint32, error) {
- buf := bytes.NewBuffer(nil)
+ buf := bufPool.Get().(*bytes.Buffer)
+ buf.Reset()
_, crc, err := d.s.NextObject(buf)
if err != nil {
return 0, err
@@ -364,6 +365,7 @@ func (d *Decoder) fillREFDeltaObjectContent(obj plumbing.EncodedObject, ref plum
obj.SetType(base.Type())
err = ApplyDelta(obj, base, buf.Bytes())
d.cachePut(obj)
+ bufPool.Put(buf)
return crc, err
}