Skip to content
Myr

walk: Use a bounded queue.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #918.

authored by Tavian Barnes · committed by David Peter · parent 5bb7a52 · Browse files · 1 file+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:src/walk.rs+4 added-2 removed
7 unmodified lines
8use std::time::{Duration, Instant};9use std::{borrow::Cow, io::Write};1011use anyhow::{anyhow, Result};12use crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender};12use crossbeam_channel::{bounded, Receiver, RecvTimeoutError, Sender};13use ignore::overrides::OverrideBuilder;14use ignore::{self, WalkBuilder};15use regex::bytes::Regex;16
33 unmodified lines
50/// jobs in parallel from a given command line and the discovered paths. Otherwise, each51/// path will simply be written to standard output.52pub fn scan(paths: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> Result<ExitCode> {53 let first_path = &paths[0];54 let (tx, rx) = unbounded();5455 // Channel capacity was chosen empircally to perform similarly to an unbounded channel56 let (tx, rx) = bounded(0x4000 * config.threads);5758 let mut override_builder = OverrideBuilder::new(first_path);5960 for pattern in &config.exclude_patterns {61 override_builder
491 unmodified lines