mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 06:54:24 +00:00
Replace bubble sort with idiomatic sort.Slice in EC shard management
- Replace O(n²) bubble sort implementation with efficient sort.Slice - More concise, readable, and performant for larger slices - Uses idiomatic Go sorting pattern
This commit is contained in:
@@ -414,13 +414,9 @@ func (s *AdminServer) GetClusterEcVolumes(page int, pageSize int, sortBy string,
|
||||
// Sort generations and check for multiple generations
|
||||
if len(volume.Generations) > 1 {
|
||||
// Sort generations (oldest first)
|
||||
for i := 0; i < len(volume.Generations); i++ {
|
||||
for j := i + 1; j < len(volume.Generations); j++ {
|
||||
if volume.Generations[i] > volume.Generations[j] {
|
||||
volume.Generations[i], volume.Generations[j] = volume.Generations[j], volume.Generations[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.Slice(volume.Generations, func(i, j int) bool {
|
||||
return volume.Generations[i] < volume.Generations[j]
|
||||
})
|
||||
volume.HasMultipleGenerations = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user