Skip to content

Commit

Permalink
perf: Multi-threaded spell checking
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
Ed Page committed Oct 25, 2019
1 parent ad11160 commit 7c64788
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,31 @@ fn run() -> Result<i32, failure::Error> {
.git_ignore(config.files.ignore_vcs())
.git_exclude(config.files.ignore_vcs())
.parents(config.files.ignore_parent());
for entry in walk.build() {
match check_entry(entry, &args, &checks) {
Ok(true) => typos_found = true,
Err(err) => {
args.format.report()(err.to_string().into());
errors_found = true
if args.threads == 1 {
for entry in walk.build() {
match check_entry(entry, &args, &checks) {
Ok(true) => typos_found = true,
Err(err) => {
args.format.report()(err.to_string().into());
errors_found = true
}
_ => (),
}
_ => (),
}
} else {
walk.build_parallel().run(|| {
Box::new(|entry: Result<ignore::DirEntry, ignore::Error>| {
match check_entry(entry, &args, &checks) {
Ok(true) => typos_found = true,
Err(err) => {
args.format.report()(err.to_string().into());
errors_found = true
}
_ => (),
}
ignore::WalkState::Continue
})
});
}
}

Expand Down

0 comments on commit 7c64788

Please sign in to comment.