Remove stable sort usage when not needed (#5586)

Stable sort is needed when we are sorting based on two or more
distinct elements. When equal elements are indistinguishable,
such as with integers, or more generally, any data where the
entire element is the key like `PartNumber`, stability is not
an issue.
master
Harshavardhana 7 years ago committed by Nitish Tiwari
parent 6b3db7556a
commit 9af254a82f
  1. 2
      cmd/fs-v1-multipart.go
  2. 2
      cmd/gateway/azure/gateway-azure.go

@ -417,7 +417,7 @@ func (fs *FSObjects) ListObjectParts(bucket, object, uploadID string, partNumber
for partNumber, etag := range partsMap {
parts = append(parts, PartInfo{PartNumber: partNumber, ETag: etag})
}
sort.SliceStable(parts, func(i int, j int) bool {
sort.Slice(parts, func(i int, j int) bool {
return parts[i].PartNumber < parts[j].PartNumber
})
i := 0

@ -806,7 +806,7 @@ func (a *azureObjects) ListObjectParts(bucket, object, uploadID string, partNumb
for _, part := range partsMap {
parts = append(parts, part)
}
sort.SliceStable(parts, func(i int, j int) bool {
sort.Slice(parts, func(i int, j int) bool {
return parts[i].PartNumber < parts[j].PartNumber
})
partsCount := 0

Loading…
Cancel
Save