diff options
author | Andrew Gallant <jamslam@gmail.com> | 2020-02-20 16:49:54 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2020-02-20 16:50:41 -0500 |
commit | 109460fce2e491aae0c2f2414e2c16141d352331 (patch) | |
tree | 2c521e01b16927ece21b25fd242aff6763388d51 | |
parent | da3431b4780a2654cdbb35613ff428cdef3fc8fe (diff) |
ignore: simplify parallel worker initialization
We can just ask the channel whether any work has been loaded. Normally
querying a channel for its length is a strong predictor of bugs, but in
this case, we do it before we ever attempt a `recv`, so it should work.
Kudos to @zsugabubus for suggesting this!
-rw-r--r-- | crates/ignore/src/walk.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/crates/ignore/src/walk.rs b/crates/ignore/src/walk.rs index ecf87b8d..0502d366 100644 --- a/crates/ignore/src/walk.rs +++ b/crates/ignore/src/walk.rs @@ -1198,7 +1198,6 @@ impl WalkParallel { let num_pending = Arc::new(AtomicUsize::new(0)); { let mut visitor = builder.build(); - let mut any_work = false; let mut paths = Vec::new().into_iter(); std::mem::swap(&mut paths, &mut self.paths); // Send the initial set of root paths to the pool of workers. Note @@ -1241,10 +1240,9 @@ impl WalkParallel { root_device: root_device, })) .unwrap(); - any_work = true; } // ... but there's no need to start workers if we don't need them. - if !any_work { + if tx.is_empty() { return; } } |