From aa7214ee3571b680b02950d91864d297bd2a7d2b Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sat, 31 Jul 2021 19:48:35 +0000 Subject: [PATCH] lib/scanner: enqueue! tokens rather than tokens.push them. This gives me the flexibility to later make tokens a Trait, and only need to fix the macro rather than every call site --- src/scanner/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/scanner/mod.rs b/src/scanner/mod.rs index 9f33fcc..5224274 100644 --- a/src/scanner/mod.rs +++ b/src/scanner/mod.rs @@ -153,7 +153,7 @@ impl Scanner let token = Token::StreamStart(StreamEncoding::UTF8); - tokens.push(token) + enqueue!(token, :self.stats => tokens); } } @@ -169,7 +169,7 @@ impl Scanner let token = Token::StreamEnd; - tokens.push(token); + enqueue!(token, :self.stats => tokens); }, (_, false) => {}, @@ -216,7 +216,7 @@ impl Scanner // A key cannot follow a document marker self.simple_key_allowed = false; - tokens.push(token) + enqueue!(token, :self.stats => tokens); } } @@ -287,7 +287,7 @@ impl Scanner advance!(*base, base.len() - buffer.len()); self.stats += stats; - tokens.push(token); + enqueue!(token, :self.stats => tokens); Ok(()) } @@ -317,7 +317,7 @@ impl Scanner advance!(*base, base.len() - buffer.len()); self.stats += stats; - tokens.push(token); + enqueue!(token, :self.stats => tokens); Ok(()) } @@ -379,7 +379,7 @@ impl Scanner advance!(*base, base.len() - buffer.len()); self.stats += stats; - tokens.push(token); + enqueue!(token, :self.stats => tokens); Ok(()) } @@ -418,7 +418,7 @@ impl Scanner advance!(*base, amt); self.stats += stats; - tokens.push(token); + enqueue!(token, :self.stats => tokens); Ok(()) } @@ -442,7 +442,7 @@ impl Scanner advance!(*base, base.len() - buffer.len()); self.stats += stats; - tokens.push(token); + enqueue!(token, :self.stats => tokens); Ok(()) } @@ -507,7 +507,7 @@ impl Scanner let token = Token::FlowEntry; - tokens.push(token); + enqueue!(token, :self.stats => tokens); Ok(()) } @@ -532,7 +532,7 @@ impl Scanner advance!(*base, :self.stats, 1); let token = Token::BlockEntry; - tokens.push(token); + enqueue!(token, :self.stats => tokens); Ok(()) }