mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 09:40:22 -07:00
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!
This commit is contained in:
parent
da3431b478
commit
109460fce2
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user