diff options
author | Santiago M. Mola <santi@mola.io> | 2017-07-24 13:36:41 +0200 |
---|---|---|
committer | Santiago M. Mola <santi@mola.io> | 2017-07-27 14:15:09 +0200 |
commit | f07672f5c3cad2e73596ab3d7ca16660f6881df6 (patch) | |
tree | c3e6162aacf6ee1c38bd3a3915dcb040b5006627 /plumbing/format | |
parent | 854ffa16f650706200a6ebb5505bb448b5c64035 (diff) | |
download | go-git-f07672f5c3cad2e73596ab3d7ca16660f6881df6.tar.gz |
plumbing/cache: use more explicit interface
* renamed Add to Put
* Get returns a second bool value to indicate if there
was hit or miss.
Diffstat (limited to 'plumbing/format')
-rw-r--r-- | plumbing/format/packfile/decoder.go | 13 |
1 files changed, 6 insertions, 7 deletions
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 } |