From 344c3db875056d4aec509f24fb2dbeaf7e2a14b6 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 9 Jun 2022 14:28:59 +0200 Subject: Refactor to pass more slices around --- src/tokenizer.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/tokenizer.rs') diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 4239520..faee8d9 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -334,7 +334,7 @@ impl Tokenizer { tokenizer.point ); let result = done(ok); - tokenizer.feed(codes, result, false) + tokenizer.feed(&codes, result, false) }, ) } @@ -373,7 +373,7 @@ impl Tokenizer { tokenizer.point ); let result = done(ok); - tokenizer.feed(codes, result, false) + tokenizer.feed(&codes, result, false) }, ) } @@ -440,11 +440,11 @@ impl Tokenizer { /// When `done: true` is passed, the EOF is fed. pub fn feed( &mut self, - codes: Vec, + codes: &[Code], start: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, drain: bool, ) -> StateFnResult { - let mut codes = codes; + let codes = codes; let mut state = State::Fn(Box::new(start)); let mut index = 0; @@ -474,7 +474,7 @@ impl Tokenizer { // Yield to a higher loop if we shouldn’t feed EOFs. if !drain { - return (state, Some(codes.split_off(index))); + return (state, Some(codes[index..].to_vec())); } loop { -- cgit