@@ -20,27 +20,25 @@ import (
20
20
type ObjectStorage struct {
21
21
options Options
22
22
23
- // deltaBaseCache is an object cache uses to cache delta's bases when
24
- deltaBaseCache cache.Object
25
-
26
- simpleObjectCache cache.Object
23
+ // objectCache is an object cache uses to cache delta's bases and also recently
24
+ // loaded loose objects
25
+ objectCache cache.Object
27
26
28
27
dir * dotgit.DotGit
29
28
index map [plumbing.Hash ]idxfile.Index
30
29
}
31
30
32
31
// NewObjectStorage creates a new ObjectStorage with the given .git directory and cache.
33
- func NewObjectStorage (dir * dotgit.DotGit , deltaBaseCache cache.Object ) * ObjectStorage {
34
- return NewObjectStorageWithOptions (dir , deltaBaseCache , Options {})
32
+ func NewObjectStorage (dir * dotgit.DotGit , objectCache cache.Object ) * ObjectStorage {
33
+ return NewObjectStorageWithOptions (dir , objectCache , Options {})
35
34
}
36
35
37
36
// NewObjectStorageWithOptions creates a new ObjectStorage with the given .git directory, cache and extra options
38
- func NewObjectStorageWithOptions (dir * dotgit.DotGit , deltaBaseCache cache.Object , ops Options ) * ObjectStorage {
37
+ func NewObjectStorageWithOptions (dir * dotgit.DotGit , objectCache cache.Object , ops Options ) * ObjectStorage {
39
38
return & ObjectStorage {
40
- options : ops ,
41
- deltaBaseCache : deltaBaseCache ,
42
- simpleObjectCache : cache .NewObjectLRU (cache .MiByte ),
43
- dir : dir ,
39
+ options : ops ,
40
+ objectCache : objectCache ,
41
+ dir : dir ,
44
42
}
45
43
}
46
44
@@ -189,7 +187,7 @@ func (s *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (p
189
187
// Create a new object storage with the DotGit(s) and check for the
190
188
// required hash object. Skip when not found.
191
189
for _ , dg := range dotgits {
192
- o := NewObjectStorage (dg , s .deltaBaseCache )
190
+ o := NewObjectStorage (dg , s .objectCache )
193
191
enobj , enerr := o .EncodedObject (t , h )
194
192
if enerr != nil {
195
193
continue
@@ -231,7 +229,7 @@ func (s *ObjectStorage) DeltaObject(t plumbing.ObjectType,
231
229
}
232
230
233
231
func (s * ObjectStorage ) getFromUnpacked (h plumbing.Hash ) (obj plumbing.EncodedObject , err error ) {
234
- if cacheObj , found := s .simpleObjectCache .Get (h ); found {
232
+ if cacheObj , found := s .objectCache .Get (h ); found {
235
233
return cacheObj , nil
236
234
}
237
235
@@ -266,7 +264,7 @@ func (s *ObjectStorage) getFromUnpacked(h plumbing.Hash) (obj plumbing.EncodedOb
266
264
return nil , err
267
265
}
268
266
269
- s .simpleObjectCache .Put (obj );
267
+ s .objectCache .Put (obj );
270
268
271
269
_ , err = io .Copy (w , r )
272
270
return obj , err
@@ -310,7 +308,7 @@ func (s *ObjectStorage) decodeObjectAt(
310
308
) (plumbing.EncodedObject , error ) {
311
309
hash , err := idx .FindHash (offset )
312
310
if err == nil {
313
- obj , ok := s .deltaBaseCache .Get (hash )
311
+ obj , ok := s .objectCache .Get (hash )
314
312
if ok {
315
313
return obj , nil
316
314
}
@@ -321,8 +319,8 @@ func (s *ObjectStorage) decodeObjectAt(
321
319
}
322
320
323
321
var p * packfile.Packfile
324
- if s .deltaBaseCache != nil {
325
- p = packfile .NewPackfileWithCache (idx , s .dir .Fs (), f , s .deltaBaseCache )
322
+ if s .objectCache != nil {
323
+ p = packfile .NewPackfileWithCache (idx , s .dir .Fs (), f , s .objectCache )
326
324
} else {
327
325
p = packfile .NewPackfile (idx , s .dir .Fs (), f )
328
326
}
@@ -432,7 +430,7 @@ func (s *ObjectStorage) buildPackfileIters(
432
430
}
433
431
return newPackfileIter (
434
432
s .dir .Fs (), pack , t , seen , s .index [h ],
435
- s .deltaBaseCache , s .options .KeepDescriptors ,
433
+ s .objectCache , s .options .KeepDescriptors ,
436
434
)
437
435
},
438
436
}, nil
0 commit comments