fix: minor allocation improvements in xlMetaV2 (#12133)

This commit is contained in:
Klaus Post
2021-05-07 18:11:05 +02:00
committed by GitHub
parent 0bab1c1895
commit 254698f126
5 changed files with 69 additions and 36 deletions
+13 -10
View File
@@ -18,21 +18,24 @@
package cmd
import (
"sort"
jsoniter "github.com/json-iterator/go"
)
// versionsSorter sorts FileInfo slices by version.
type versionsSorter []FileInfo
func (v versionsSorter) Len() int { return len(v) }
func (v versionsSorter) Swap(i, j int) { v[i], v[j] = v[j], v[i] }
func (v versionsSorter) Less(i, j int) bool {
if v[i].IsLatest {
return true
}
if v[j].IsLatest {
return false
}
return v[i].ModTime.After(v[j].ModTime)
func (v versionsSorter) sort() {
sort.Slice(v, func(i, j int) bool {
if v[i].IsLatest {
return true
}
if v[j].IsLatest {
return false
}
return v[i].ModTime.After(v[j].ModTime)
})
}
func getFileInfoVersions(xlMetaBuf []byte, volume, path string) (FileInfoVersions, error) {