aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/decoder.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2017-07-24 13:36:41 +0200
committerSantiago M. Mola <santi@mola.io>2017-07-27 14:15:09 +0200
commitf07672f5c3cad2e73596ab3d7ca16660f6881df6 (patch)
treec3e6162aacf6ee1c38bd3a3915dcb040b5006627 /plumbing/format/packfile/decoder.go
parent854ffa16f650706200a6ebb5505bb448b5c64035 (diff)
downloadgo-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/packfile/decoder.go')
-rw-r--r--plumbing/format/packfile/decoder.go13
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
}