Skip to content
Myr

walk: Simplify the code in scan() a bit

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

authored by Tavian Barnes · committed by David Peter · parent cd8ec44 · Browse files · 1 file+6 added−9 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+6 added−9 removed

  • other:+6 added−9 removed

1 file+6 added−9 removed

modified:src/walk.rs+6 added-9 removed
47 unmodified lines
48///49/// If the `--exec` argument was supplied, this will create a thread pool for executing50/// 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(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> Result<ExitCode> {53 let mut path_iter = path_vec.iter();54 let first_path_buf = path_iter55 .next()56 .expect("Error: Path vector can not be empty");52pub fn scan(paths: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> Result<ExitCode> {53 let first_path = &paths[0];54 let (tx, rx) = channel();5559 let mut override_builder = OverrideBuilder::new(first_path_buf.as_path());56 let mut override_builder = OverrideBuilder::new(first_path);5758 for pattern in &config.exclude_patterns {59 override_builder60 .add(pattern)
2 unmodified lines
63 let overrides = override_builder64 .build()65 .map_err(|_| anyhow!("Mismatch in exclude patterns"))?;6670 let mut walker = WalkBuilder::new(first_path_buf.as_path());67 let mut walker = WalkBuilder::new(first_path);68 walker69 .hidden(config.ignore_hidden)70 .ignore(config.read_fdignore)71 .parents(config.read_parent_ignore && (config.read_fdignore || config.read_vcsignore))
45 unmodified lines
117 None => (),118 }119 }120124 for path_entry in path_iter {125 walker.add(path_entry.as_path());121 for path in &paths[1..] {122 walker.add(path);123 }124125 let parallel_walker = walker.threads(config.threads).build_parallel();126
430 unmodified lines