diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-20 12:34:06 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-20 12:34:06 +0200 |
commit | 7894ec75a7070591c3499fce1f409563c4edc7d7 (patch) | |
tree | 170d736268a30b728f28b164213a0a0ac47414da /src/tokenizer.rs | |
parent | 7ec35068c86a546dac8172e74e8a34e3b6813eb2 (diff) | |
download | markdown-rs-7894ec75a7070591c3499fce1f409563c4edc7d7.tar.gz markdown-rs-7894ec75a7070591c3499fce1f409563c4edc7d7.tar.bz2 markdown-rs-7894ec75a7070591c3499fce1f409563c4edc7d7.zip |
Refactor to use less vecs for events
Diffstat (limited to 'src/tokenizer.rs')
-rw-r--r-- | src/tokenizer.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 8813bdc..cba1752 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -91,7 +91,7 @@ pub type StateFnResult = (State, Option<Vec<Code>>); /// Resolvers are supposed to change the list of events, because parsing is /// sometimes messy, and they help expose a cleaner interface of events to /// the compiler and other users. -pub type Resolver = dyn FnOnce(&mut Tokenizer) -> Vec<Event>; +pub type Resolver = dyn FnOnce(&mut Tokenizer); /// The result of a state. pub enum State { @@ -167,8 +167,6 @@ struct InternalState { point: Point, } -// #[derive(Debug)] - /// A tokenizer itself. #[allow(clippy::struct_excessive_bools)] pub struct Tokenizer<'a> { @@ -288,12 +286,12 @@ impl<'a> Tokenizer<'a> { /// Define a jump between two places. pub fn define_skip(&mut self, point: &Point, index: usize) { - define_skip_current_impl(self, point.line, (point.column, point.offset, index)); + define_skip_impl(self, point.line, (point.column, point.offset, index)); } /// Define the current place as a jump between two places. pub fn define_skip_current(&mut self) { - define_skip_current_impl( + define_skip_impl( self, self.point.line, (self.point.column, self.point.offset, self.index), @@ -629,7 +627,7 @@ impl<'a> Tokenizer<'a> { while !self.resolvers.is_empty() { let resolver = self.resolvers.remove(0); - self.events = resolver(self); + resolver(self); } } @@ -768,7 +766,7 @@ fn flush_impl( /// /// This defines how much columns, offsets, and the `index` are increased when /// consuming a line ending. -fn define_skip_current_impl(tokenizer: &mut Tokenizer, line: usize, info: (usize, usize, usize)) { +fn define_skip_impl(tokenizer: &mut Tokenizer, line: usize, info: (usize, usize, usize)) { log::debug!("position: define skip: {:?} -> ({:?})", line, info); let at = line - tokenizer.line_start; |