diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-12-20 19:11:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-20 19:11:16 +0100 |
commit | 50725139e8b96f88d74e253c8312fd4864640771 (patch) | |
tree | 70d0c7ce9b0d9201a3e94b19948d14b815337c76 /storage/filesystem | |
parent | ca59809a0c74f6af498347a102a64242e26b0ab0 (diff) | |
parent | e39559fba6ea936c5f4659c03c22f9a5a256a4d7 (diff) | |
download | go-git-50725139e8b96f88d74e253c8312fd4864640771.tar.gz |
Merge pull request #698 from jfontan/improvement/use-decoder-cache
plumbing: cache, enforce the use of cache in packfile decoder
Diffstat (limited to 'storage/filesystem')
-rw-r--r-- | storage/filesystem/object.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go index fd52ed5..3ec7304 100644 --- a/storage/filesystem/object.go +++ b/storage/filesystem/object.go @@ -18,11 +18,9 @@ import ( "gopkg.in/src-d/go-billy.v4" ) -const DefaultMaxDeltaBaseCacheSize = 92 * cache.MiByte - type ObjectStorage struct { - // DeltaBaseCache is an object cache uses to cache delta's bases when - DeltaBaseCache cache.Object + // deltaBaseCache is an object cache uses to cache delta's bases when + deltaBaseCache cache.Object dir *dotgit.DotGit index map[plumbing.Hash]*packfile.Index @@ -30,7 +28,7 @@ type ObjectStorage struct { func newObjectStorage(dir *dotgit.DotGit) (ObjectStorage, error) { s := ObjectStorage{ - DeltaBaseCache: cache.NewObjectLRU(DefaultMaxDeltaBaseCacheSize), + deltaBaseCache: cache.NewObjectLRUDefault(), dir: dir, } @@ -287,13 +285,13 @@ func (s *ObjectStorage) decodeObjectAt( p := packfile.NewScanner(f) - d, err := packfile.NewDecoder(p, memory.NewStorage()) + d, err := packfile.NewDecoderWithCache(p, memory.NewStorage(), + s.deltaBaseCache) if err != nil { return nil, err } d.SetIndex(idx) - d.DeltaBaseCache = s.DeltaBaseCache obj, err := d.DecodeObjectAt(offset) return obj, err } @@ -400,7 +398,7 @@ func (s *ObjectStorage) buildPackfileIters(t plumbing.ObjectType, seen map[plumb return nil, err } - iter, err := newPackfileIter(pack, t, seen, s.index[h], s.DeltaBaseCache) + iter, err := newPackfileIter(pack, t, seen, s.index[h], s.deltaBaseCache) if err != nil { return nil, err } @@ -433,13 +431,12 @@ func newPackfileIter(f billy.File, t plumbing.ObjectType, seen map[plumbing.Hash return nil, err } - d, err := packfile.NewDecoderForType(s, memory.NewStorage(), t) + d, err := packfile.NewDecoderForType(s, memory.NewStorage(), t, cache) if err != nil { return nil, err } d.SetIndex(index) - d.DeltaBaseCache = cache return &packfileIter{ f: f, |