refactor(parser): Switch to by-ref builder

Since nothing is being moved into `Parser`, we don't get any performance
benefit with a moving builder, so switching to a by-ref builder.
This commit is contained in:
Ed Page 2019-07-24 06:48:44 -06:00
parent 3cf9d8672c
commit 039664339d

View file

@ -16,12 +16,12 @@ impl ParserBuilder {
Default::default() Default::default()
} }
pub fn ignore_hex(mut self, yes: bool) -> Self { pub fn ignore_hex(&mut self, yes: bool) -> &mut Self {
self.ignore_hex = yes; self.ignore_hex = yes;
self self
} }
pub fn build(self) -> Parser { pub fn build(&self) -> Parser {
let pattern = r#"\b(\p{Alphabetic}|\d|_|')+\b"#; let pattern = r#"\b(\p{Alphabetic}|\d|_|')+\b"#;
let words_str = regex::Regex::new(pattern).unwrap(); let words_str = regex::Regex::new(pattern).unwrap();
let words_bytes = regex::bytes::Regex::new(pattern).unwrap(); let words_bytes = regex::bytes::Regex::new(pattern).unwrap();