From 6a46a7eb543789c7012bf0f964e1b6b38eca150c Mon Sep 17 00:00:00 2001 From: Miguel Molina Date: Mon, 4 Sep 2017 18:23:26 +0200 Subject: packfile: improve performance a little by reducing gc pressure Signed-off-by: Miguel Molina --- plumbing/format/packfile/decoder.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plumbing/format/packfile/decoder.go') 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 } -- cgit