This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 21
21
ErrZLib = NewError ("zlib reading error" )
22
22
)
23
23
24
+ // When reading small objects from packfile it is beneficial to do so at
25
+ // once to exploit the buffered I/O. In many cases the objects are so small
26
+ // that they were already loaded to memory when the object header was
27
+ // loaded from the packfile. Wrapping in FSObject would cause this buffered
28
+ // data to be thrown away and then re-read later, with the additional
29
+ // seeking causing reloads from disk. Objects smaller than this threshold
30
+ // are now always read into memory and stored in cache instead of being
31
+ // wrapped in FSObject.
32
+ const smallObjectThreshold = 16 * 1024
33
+
24
34
// Packfile allows retrieving information from inside a packfile.
25
35
type Packfile struct {
26
36
idxfile.Index
@@ -208,7 +218,7 @@ func (p *Packfile) objectAtOffset(offset int64) (plumbing.EncodedObject, error)
208
218
209
219
// If we have no filesystem, we will return a MemoryObject instead
210
220
// of an FSObject.
211
- if p .fs == nil || h .Length <= 16 * 1024 {
221
+ if p .fs == nil || h .Length <= smallObjectThreshold {
212
222
return p .getNextObject (h )
213
223
}
214
224
You can’t perform that action at this time.
0 commit comments