From f07672f5c3cad2e73596ab3d7ca16660f6881df6 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Mon, 24 Jul 2017 13:36:41 +0200 Subject: plumbing/cache: use more explicit interface * renamed Add to Put * Get returns a second bool value to indicate if there was hit or miss. --- plumbing/format/packfile/decoder.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'plumbing/format') diff --git a/plumbing/format/packfile/decoder.go b/plumbing/format/packfile/decoder.go index 39680a3..3d2eb3b 100644 --- a/plumbing/format/packfile/decoder.go +++ b/plumbing/format/packfile/decoder.go @@ -355,9 +355,8 @@ func (d *Decoder) fillREFDeltaObjectContent(obj plumbing.EncodedObject, ref plum return 0, err } - base := d.cache.Get(ref) - - if base == nil { + base, ok := d.cache.Get(ref) + if !ok { base, err = d.recallByHash(ref) if err != nil { return 0, err @@ -366,7 +365,7 @@ func (d *Decoder) fillREFDeltaObjectContent(obj plumbing.EncodedObject, ref plum obj.SetType(base.Type()) err = ApplyDelta(obj, base, buf.Bytes()) - d.cache.Add(obj) + d.cache.Put(obj) return crc, err } @@ -381,10 +380,10 @@ func (d *Decoder) fillOFSDeltaObjectContent(obj plumbing.EncodedObject, offset i e, ok := d.idx.LookupOffset(uint64(offset)) var base plumbing.EncodedObject if ok { - base = d.cache.Get(e.Hash) + base, ok = d.cache.Get(e.Hash) } - if base == nil { + if !ok { base, err = d.recallByOffset(offset) if err != nil { return 0, err @@ -393,7 +392,7 @@ func (d *Decoder) fillOFSDeltaObjectContent(obj plumbing.EncodedObject, offset i obj.SetType(base.Type()) err = ApplyDelta(obj, base, buf.Bytes()) - d.cache.Add(obj) + d.cache.Put(obj) return crc, err } -- cgit