Skip to content
Myr

avoid cloning command, in the wake of 9d26b74

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

authored by Alexandru Macovei · committed by David Peter · parent fe53af0 · Browse files · 3 files+4 added−10 removed
This commit

State

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

Diff stats

3 files+4 added−10 removed

  • other:+4 added−10 removed

3 files+4 added−10 removed

modified:src/internal/opts.rs+2 added-2 removed
3 unmodified lines
4 FileTypes,5};6use lscolors::LsColors;7use regex::RegexSet;8use std::{path::PathBuf, time::Duration};8use std::{path::PathBuf, sync::Arc, time::Duration};910/// Configuration options for *fd*.11pub struct FdOptions {12 /// Whether the search is case-sensitive or case-insensitive.
45 unmodified lines
58 /// The value (if present) will be a lowercase string without leading dots.59 pub extensions: Option<RegexSet>,6061 /// If a value is supplied, each item found will be used to generate and execute commands.62 pub command: Option<CommandTemplate>,62 pub command: Option<Arc<CommandTemplate>>,6364 /// A list of glob patterns that should be excluded from the search.65 pub exclude_patterns: Vec<String>,66
12 unmodified lines
modified:src/main.rs+1 added-1 removed
229 unmodified lines
230 print_error_and_exit!("{}", err.description());231 }232 }233 }),234 command,234 command: command.map(Arc::new),235 exclude_patterns: matches236 .values_of("exclude")237 .map(|v| v.map(|p| String::from("!") + p).collect())238 .unwrap_or_else(|| vec![]),
24 unmodified lines
modified:src/walk.rs+1 added-7 removed
148 unmodified lines
149 let shared_rx = Arc::new(Mutex::new(rx));150151 let out_perm = Arc::new(Mutex::new(()));152153 // TODO: the following line is a workaround to replace the `unsafe` block that was154 // previously used here to avoid the (unnecessary?) cloning of the command. The155 // `unsafe` block caused problems on some platforms (SIGILL instructions on Linux) and156 // therefore had to be removed.157 let cmd = Arc::new(cmd.clone());158153 // Each spawned job will store it's thread handle in here.154 let mut handles = Vec::with_capacity(threads);155 for _ in 0..threads {156 let rx = Arc::clone(&shared_rx);163 let cmd = Arc::clone(&cmd);157 let cmd = Arc::clone(cmd);158 let out_perm = Arc::clone(&out_perm);159160 // Spawn a job thread that will listen for and execute inputs.161 let handle =
210 unmodified lines