Skip to content

Commit 19a2b60

Browse files
committedFeb 13, 2025
Do a reverse sort using std::cmp::Reverse
Potential speedup by avoiding doing the reversal as a separate step. Signed-off-by: J Robert Ray <[email protected]>
1 parent e0c9240 commit 19a2b60

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed
 

‎crates/spk-solve/crates/package-iterator/src/package_iterator.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -640,20 +640,18 @@ impl SortedBuildIterator {
640640
self.builds.make_contiguous().sort_by_cached_key(|hm| {
641641
// Pull an arbitrary spec out from the hashmap
642642
let spec = &hm.iter().next().expect("non-empty hashmap").1 .0;
643-
SortedBuildIterator::make_option_values_build_key(
643+
// Reverse the sort to get the build with the highest
644+
// "numbers" in the earlier parts of its key to come first,
645+
// which also reverse sorts the text values, i.e. "on" will
646+
// come before "off".
647+
std::cmp::Reverse(SortedBuildIterator::make_option_values_build_key(
644648
spec,
645649
&key_entry_names,
646650
&build_name_values,
647651
builds_with_impossible_requests.contains_key(&spec.ident().clone()),
648-
)
652+
))
649653
});
650654

651-
// Reverse the sort to get the build with the highest
652-
// "numbers" in the earlier parts of its key to come first,
653-
// which also reverse sorts the text values, i.e. "on" will
654-
// come before "off".
655-
self.builds.make_contiguous().reverse();
656-
657655
let duration: Duration = start.elapsed();
658656
tracing::info!(
659657
target: BUILD_SORT_TARGET,

0 commit comments

Comments
 (0)