Merge pull request #309 from epage/clean

refactor(typos): Remove unused calculations
This commit is contained in:
Ed Page 2021-07-06 09:25:08 -07:00 committed by GitHub
commit 2441504881
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,10 +46,7 @@ impl Tokenizer {
} else { } else {
itertools::Either::Right(ascii_parser::iter_identifiers(content.as_bytes())) itertools::Either::Right(ascii_parser::iter_identifiers(content.as_bytes()))
}; };
iter.filter_map(move |identifier| { iter.map(move |identifier| self.transform(identifier, content.as_bytes()))
let offset = offset(content.as_bytes(), identifier.as_bytes());
self.transform(identifier, offset)
})
} }
pub fn parse_bytes<'c>(&'c self, content: &'c [u8]) -> impl Iterator<Item = Identifier<'c>> { pub fn parse_bytes<'c>(&'c self, content: &'c [u8]) -> impl Iterator<Item = Identifier<'c>> {
@ -60,17 +57,15 @@ impl Tokenizer {
} else { } else {
itertools::Either::Right(ascii_parser::iter_identifiers(content)) itertools::Either::Right(ascii_parser::iter_identifiers(content))
}; };
iter.filter_map(move |identifier| { iter.map(move |identifier| self.transform(identifier, content))
let offset = offset(content, identifier.as_bytes());
self.transform(identifier, offset)
})
} }
fn transform<'i>(&self, identifier: &'i str, offset: usize) -> Option<Identifier<'i>> { fn transform<'i>(&self, identifier: &'i str, content: &[u8]) -> Identifier<'i> {
debug_assert!(!identifier.is_empty()); debug_assert!(!identifier.is_empty());
let case = Case::None; let case = Case::None;
Some(Identifier::new_unchecked(identifier, case, offset)) let offset = offset(content, identifier.as_bytes());
Identifier::new_unchecked(identifier, case, offset)
} }
} }