fix: pre-allocate certain slices with expected capacity (#12044)

Avoids append() based tiny allocations on known
allocated slices repeated access.
This commit is contained in:
Harshavardhana
2021-04-12 13:45:06 -07:00
committed by GitHub
parent f1bc857f66
commit e85b28398b
4 changed files with 16 additions and 12 deletions

View File

@@ -1147,7 +1147,7 @@ func (z xlMetaV2) TotalSize() int64 {
// showPendingDeletes is set to true if ListVersions needs to list objects marked deleted
// but waiting to be replicated
func (z xlMetaV2) ListVersions(volume, path string) ([]FileInfo, time.Time, error) {
var versions []FileInfo
versions := make([]FileInfo, 0, len(z.Versions))
var err error
for _, version := range z.Versions {