From 53679e4c43e472b2f51d9568455caa10ad399fc4 Mon Sep 17 00:00:00 2001
From: Tavian Barnes <tavianator@tavianator.com>
Date: Wed, 11 Oct 2023 16:17:29 -0400
Subject: [PATCH] ignore: simplify the work-stealing strategy

There's no particular reason for this change. I happened to be looking
at the code again and realized that stealing from your left neighbour
or your right neighbour shouldn't make a difference (and indeed perf is
the same in my benchmarks).

Closes #2624
---
 crates/ignore/src/walk.rs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/crates/ignore/src/walk.rs b/crates/ignore/src/walk.rs
index 2d754da1..4fee1d88 100644
--- a/crates/ignore/src/walk.rs
+++ b/crates/ignore/src/walk.rs
@@ -1439,15 +1439,15 @@ impl Stack {
 
     /// Steal a message from another queue.
     fn steal(&self) -> Option<Message> {
-        // For fairness, try to steal from index - 1, then index - 2, ... 0,
-        // then wrap around to len - 1, len - 2, ... index + 1.
+        // For fairness, try to steal from index + 1, index + 2, ... len - 1,
+        // then wrap around to 0, 1, ... index - 1.
         let (left, right) = self.stealers.split_at(self.index);
         // Don't steal from ourselves
         let right = &right[1..];
 
-        left.iter()
-            .rev()
-            .chain(right.iter().rev())
+        right
+            .iter()
+            .chain(left.iter())
             .map(|s| s.steal_batch_and_pop(&self.deque))
             .find_map(|s| s.success())
     }