diff options
Diffstat (limited to 'object/tree/parse.go')
| -rw-r--r-- | object/tree/parse.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/object/tree/parse.go b/object/tree/parse.go index e89ce0fa..74f704f7 100644 --- a/object/tree/parse.go +++ b/object/tree/parse.go @@ -28,6 +28,11 @@ func Parse(body []byte, objectFormat id.ObjectFormat) (*Tree, error) { idSize := objectFormat.Size() seen := make(map[string]struct{}) + const minEntryOverhead = 5 + 1 + 1 + 1 // mode, space, name, NUL + if estimate := len(body) / (minEntryOverhead + idSize); estimate > 0 { + tree.entries = make([]Entry, 0, estimate) + } + i := 0 for i < len(body) { space := bytes.IndexByte(body[i:], ' ') |
