diff rust/hg-core/src/discovery.rs @ 49930:e98fd81bb151

rust-clippy: fix most warnings in `hg-core` All of these are simple changes that for the most part are clear improvements and the rest are at most equivalent. The remaining warnings have to be fixed either with a bigger refactor like for the nested "revlog" module, or in the dependency `bytes-cast`, which we own. This will be done sometime in the future.
author Rapha?l Gom?s <rgomes@octobus.net>
date Mon, 09 Jan 2023 19:18:43 +0100
parents 26114bd6ec60
children 4c5f6e95df84
line wrap: on
line diff
--- a/rust/hg-core/src/discovery.rs	Mon Jan 09 19:14:14 2023 +0100
+++ b/rust/hg-core/src/discovery.rs	Mon Jan 09 19:18:43 2023 +0100
@@ -194,7 +194,7 @@
         size: usize,
     ) -> Vec<Revision> {
         if !self.randomize {
-            sample.sort();
+            sample.sort_unstable();
             sample.truncate(size);
             return sample;
         }
@@ -513,14 +513,14 @@
     ) -> Vec<Revision> {
         let mut as_vec: Vec<Revision> =
             disco.undecided.as_ref().unwrap().iter().cloned().collect();
-        as_vec.sort();
+        as_vec.sort_unstable();
         as_vec
     }
 
     fn sorted_missing(disco: &PartialDiscovery<SampleGraph>) -> Vec<Revision> {
         let mut as_vec: Vec<Revision> =
             disco.missing.iter().cloned().collect();
-        as_vec.sort();
+        as_vec.sort_unstable();
         as_vec
     }
 
@@ -529,7 +529,7 @@
     ) -> Result<Vec<Revision>, GraphError> {
         let mut as_vec: Vec<Revision> =
             disco.common_heads()?.iter().cloned().collect();
-        as_vec.sort();
+        as_vec.sort_unstable();
         Ok(as_vec)
     }
 
@@ -621,7 +621,7 @@
         disco.undecided = Some((1..=13).collect());
 
         let mut sample_vec = disco.take_quick_sample(vec![], 4)?;
-        sample_vec.sort();
+        sample_vec.sort_unstable();
         assert_eq!(sample_vec, vec![10, 11, 12, 13]);
         Ok(())
     }
@@ -632,7 +632,7 @@
         disco.ensure_undecided()?;
 
         let mut sample_vec = disco.take_quick_sample(vec![12], 4)?;
-        sample_vec.sort();
+        sample_vec.sort_unstable();
         // r12's only parent is r9, whose unique grand-parent through the
         // diamond shape is r4. This ends there because the distance from r4
         // to the root is only 3.
@@ -650,11 +650,11 @@
         assert_eq!(cache.get(&10).cloned(), None);
 
         let mut children_4 = cache.get(&4).cloned().unwrap();
-        children_4.sort();
+        children_4.sort_unstable();
         assert_eq!(children_4, vec![5, 6, 7]);
 
         let mut children_7 = cache.get(&7).cloned().unwrap();
-        children_7.sort();
+        children_7.sort_unstable();
         assert_eq!(children_7, vec![9, 11]);
 
         Ok(())
@@ -684,7 +684,7 @@
         let (sample_set, size) = disco.bidirectional_sample(7)?;
         assert_eq!(size, 7);
         let mut sample: Vec<Revision> = sample_set.into_iter().collect();
-        sample.sort();
+        sample.sort_unstable();
         // our DAG is a bit too small for the results to be really interesting
         // at least it shows that
         // - we went both ways