diff --git a/benches/file.rs b/benches/file.rs index 5f69285..0cfea12 100644 --- a/benches/file.rs +++ b/benches/file.rs @@ -13,13 +13,14 @@ fn process_empty(b: &mut test::Bencher) { sample_path.write_str(data::EMPTY).unwrap(); let corrections = typos::Dictionary::new(); + let parser = typos::tokens::Parser::new(); b.iter(|| { typos::process_file( sample_path.path(), &corrections, true, true, - true, + &parser, false, typos::report::print_silent, ) @@ -35,13 +36,14 @@ fn process_no_tokens(b: &mut test::Bencher) { sample_path.write_str(data::NO_TOKENS).unwrap(); let corrections = typos::Dictionary::new(); + let parser = typos::tokens::Parser::new(); b.iter(|| { typos::process_file( sample_path.path(), &corrections, true, true, - true, + &parser, false, typos::report::print_silent, ) @@ -57,13 +59,14 @@ fn process_single_token(b: &mut test::Bencher) { sample_path.write_str(data::SINGLE_TOKEN).unwrap(); let corrections = typos::Dictionary::new(); + let parser = typos::tokens::Parser::new(); b.iter(|| { typos::process_file( sample_path.path(), &corrections, true, true, - true, + &parser, false, typos::report::print_silent, ) @@ -79,13 +82,14 @@ fn process_sherlock(b: &mut test::Bencher) { sample_path.write_str(data::SHERLOCK).unwrap(); let corrections = typos::Dictionary::new(); + let parser = typos::tokens::Parser::new(); b.iter(|| { typos::process_file( sample_path.path(), &corrections, true, true, - true, + &parser, false, typos::report::print_silent, ) @@ -101,13 +105,14 @@ fn process_code(b: &mut test::Bencher) { sample_path.write_str(data::CODE).unwrap(); let corrections = typos::Dictionary::new(); + let parser = typos::tokens::Parser::new(); b.iter(|| { typos::process_file( sample_path.path(), &corrections, true, true, - true, + &parser, false, typos::report::print_silent, ) @@ -123,13 +128,14 @@ fn process_corpus(b: &mut test::Bencher) { sample_path.write_str(data::CORPUS).unwrap(); let corrections = typos::Dictionary::new(); + let parser = typos::tokens::Parser::new(); b.iter(|| { typos::process_file( sample_path.path(), &corrections, true, true, - true, + &parser, false, typos::report::print_silent, ) diff --git a/src/lib.rs b/src/lib.rs index f357182..fb61469 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,11 +19,10 @@ pub fn process_file( dictionary: &Dictionary, check_filenames: bool, check_files: bool, - ignore_hex: bool, + parser: &tokens::Parser, binary: bool, report: report::Report, ) -> Result { - let parser = tokens::ParserBuilder::new().ignore_hex(ignore_hex).build(); let mut typos_found = false; if check_filenames { diff --git a/src/main.rs b/src/main.rs index 2e662a7..a512db9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -261,6 +261,10 @@ fn run() -> Result { let ignore_hex = options.ignore_hex().unwrap_or(true); let binary = options.binary().unwrap_or(false); + let parser = typos::tokens::ParserBuilder::new() + .ignore_hex(ignore_hex) + .build(); + let first_path = &options .path .get(0) @@ -284,7 +288,7 @@ fn run() -> Result { &dictionary, check_filenames, check_files, - ignore_hex, + &parser, binary, options.format.report(), )? {