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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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