aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 187a0ebe6..a270eb481 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -309,8 +309,13 @@ pub fn analysis_stats(
309} 309}
310 310
311fn shuffle<T>(rng: &mut Rand32, slice: &mut [T]) { 311fn shuffle<T>(rng: &mut Rand32, slice: &mut [T]) {
312 for i in (1..slice.len()).rev() { 312 for i in 0..slice.len() {
313 let idx = rng.rand_range(0..i as u32) as usize; 313 randomize_first(rng, &mut slice[i..]);
314 slice.swap(idx, i) 314 }
315
316 fn randomize_first<T>(rng: &mut Rand32, slice: &mut [T]) {
317 assert!(!slice.is_empty());
318 let idx = rng.rand_range(0..slice.len() as u32) as usize;
319 slice.swap(0, idx);
315 } 320 }
316} 321}