avoid cloning command, in the wake of 9d26b74

This commit is contained in:
Alexandru Macovei 2019-01-30 00:09:45 +02:00 committed by David Peter
parent fe53af064b
commit c2b46f247f
3 changed files with 4 additions and 10 deletions

View file

@ -5,7 +5,7 @@ use crate::internal::{
};
use lscolors::LsColors;
use regex::RegexSet;
use std::{path::PathBuf, time::Duration};
use std::{path::PathBuf, sync::Arc, time::Duration};
/// Configuration options for *fd*.
pub struct FdOptions {
@ -59,7 +59,7 @@ pub struct FdOptions {
pub extensions: Option<RegexSet>,
/// If a value is supplied, each item found will be used to generate and execute commands.
pub command: Option<CommandTemplate>,
pub command: Option<Arc<CommandTemplate>>,
/// A list of glob patterns that should be excluded from the search.
pub exclude_patterns: Vec<String>,

View file

@ -231,7 +231,7 @@ fn main() {
}
}
}),
command,
command: command.map(Arc::new),
exclude_patterns: matches
.values_of("exclude")
.map(|v| v.map(|p| String::from("!") + p).collect())

View file

@ -150,17 +150,11 @@ fn spawn_receiver(
let out_perm = Arc::new(Mutex::new(()));
// TODO: the following line is a workaround to replace the `unsafe` block that was
// previously used here to avoid the (unnecessary?) cloning of the command. The
// `unsafe` block caused problems on some platforms (SIGILL instructions on Linux) and
// therefore had to be removed.
let cmd = Arc::new(cmd.clone());
// Each spawned job will store it's thread handle in here.
let mut handles = Vec::with_capacity(threads);
for _ in 0..threads {
let rx = Arc::clone(&shared_rx);
let cmd = Arc::clone(&cmd);
let cmd = Arc::clone(cmd);
let out_perm = Arc::clone(&out_perm);
// Spawn a job thread that will listen for and execute inputs.