@@ -1182,19 +1182,15 @@ func (l *L0CompactionFiles) addFile(f *TableMetadata) {
1182
1182
l .maxIntervalIndex = max (l .maxIntervalIndex , f .maxIntervalIndex )
1183
1183
}
1184
1184
1185
- // Helper to order intervals being considered for compaction.
1186
1185
type intervalAndScore struct {
1187
1186
interval int
1188
1187
score int
1189
1188
}
1190
- type intervalSorterByDecreasingScore []intervalAndScore
1191
1189
1192
- func (is intervalSorterByDecreasingScore ) Len () int { return len (is ) }
1193
- func (is intervalSorterByDecreasingScore ) Less (i , j int ) bool {
1194
- return is [i ].score > is [j ].score
1195
- }
1196
- func (is intervalSorterByDecreasingScore ) Swap (i , j int ) {
1197
- is [i ], is [j ] = is [j ], is [i ]
1190
+ func sortIntervalsByDecreasingScore (s []intervalAndScore ) {
1191
+ slices .SortFunc (s , func (a , b intervalAndScore ) int {
1192
+ return stdcmp .Compare (b .score , a .score )
1193
+ })
1198
1194
}
1199
1195
1200
1196
// Compactions:
@@ -1401,7 +1397,7 @@ func (s *l0Sublevels) PickBaseCompaction(
1401
1397
scoredIntervals = append (scoredIntervals , intervalAndScore {interval : i , score : depth + sublevelCount })
1402
1398
}
1403
1399
}
1404
- sort . Sort ( intervalSorterByDecreasingScore ( scoredIntervals ) )
1400
+ sortIntervalsByDecreasingScore ( scoredIntervals )
1405
1401
1406
1402
// Optimization to avoid considering different intervals that
1407
1403
// are likely to choose the same seed file. Again this is just
@@ -1614,7 +1610,7 @@ func (s *l0Sublevels) PickIntraL0Compaction(
1614
1610
}
1615
1611
scoredIntervals [i ] = intervalAndScore {interval : i , score : depth }
1616
1612
}
1617
- sort . Sort ( intervalSorterByDecreasingScore ( scoredIntervals ) )
1613
+ sortIntervalsByDecreasingScore ( scoredIntervals )
1618
1614
1619
1615
// Optimization to avoid considering different intervals that are likely to
1620
1616
// choose the same seed file. Again this is just to reduce wasted work.
0 commit comments