Avoid Unstable Sort (#12455)

* dont use unstable sort

* remove comment

* add clippy rule
This commit is contained in:
Shawn Tabrizi authored and GitHub committed 2022-10-11 18:41:43 +00:00
1 parent fbdfa84cd7
commit 023aa03fea
9 files changed
+14 -17

No files matched your search

@@ -1976,11 +1976,7 @@ pub mod env {
data_len: u32,
) -> Result<(), TrapReason> {
fn has_duplicates<T: Ord>(items: &mut Vec<T>) -> bool {
// # Warning
//
// Unstable sorts are non-deterministic across architectures. The usage here is OK
// because we are rejecting duplicates which removes the non determinism.
items.sort_unstable();
items.sort();
// Find any two consecutive equal elements.
items.windows(2).any(|w| match &w {
&[a, b] => a == b,