mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 09:01:04 -05:00
refactor: Calculate threading where it is needed
This commit is contained in:
parent
2e1b95fec1
commit
b7d412c20e
1 changed files with 4 additions and 13 deletions
17
src/main.rs
17
src/main.rs
|
@ -96,16 +96,6 @@ struct Args {
|
|||
verbose: clap_verbosity_flag::Verbosity,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
pub fn infer(mut self) -> Self {
|
||||
if self.path.len() == 1 && self.path[0].is_file() {
|
||||
self.threads = 1;
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(rename_all = "kebab-case")]
|
||||
pub struct FileArgs {
|
||||
|
@ -469,7 +459,7 @@ fn check_entry(
|
|||
}
|
||||
|
||||
fn run() -> Result<i32, anyhow::Error> {
|
||||
let args = Args::from_args().infer();
|
||||
let args = Args::from_args();
|
||||
|
||||
init_logging(args.verbose.log_level());
|
||||
|
||||
|
@ -514,6 +504,9 @@ fn run() -> Result<i32, anyhow::Error> {
|
|||
.check_files(config.default.check_file())
|
||||
.binary(config.files.binary());
|
||||
|
||||
let threads = if path.is_file() { 1 } else { args.threads };
|
||||
let single_threaded = threads == 1;
|
||||
|
||||
let mut walk = ignore::WalkBuilder::new(path);
|
||||
walk.threads(args.threads)
|
||||
.hidden(config.files.ignore_hidden())
|
||||
|
@ -525,8 +518,6 @@ fn run() -> Result<i32, anyhow::Error> {
|
|||
|
||||
let reporter = args.format.reporter();
|
||||
|
||||
let single_threaded = args.threads == 1;
|
||||
|
||||
if args.files {
|
||||
if single_threaded {
|
||||
for entry in walk.build() {
|
||||
|
|
Loading…
Reference in a new issue