summaryrefslogtreecommitdiff
path: root/src/parse/tokens.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-09 14:56:12 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-09 14:56:12 +0100
commit5a0e7cc36107c03001696b6dfbfdeb47abd2aeac (patch)
treed16c17dfb8da031b72b81609cc63ba73321dca58 /src/parse/tokens.rs
parente089b6ea40015e012302dc55ac5d6cb42ca4876e (diff)
Coalesce text and simple spaces for high performance
Co-Authored-By: Martin Haug <mhaug@live.de>
Diffstat (limited to 'src/parse/tokens.rs')
-rw-r--r--src/parse/tokens.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs
index 970c0dd6..0c125b4b 100644
--- a/src/parse/tokens.rs
+++ b/src/parse/tokens.rs
@@ -202,9 +202,18 @@ impl<'s> Tokens<'s> {
'~' | '*' | '_' | '`' | '$' | '-' | '\\'
};
- self.s.eat_until(|c| {
- TABLE.get(c as usize).copied().unwrap_or_else(|| c.is_whitespace())
- });
+ loop {
+ self.s.eat_until(|c| {
+ TABLE.get(c as usize).copied().unwrap_or_else(|| c.is_whitespace())
+ });
+
+ let mut s = self.s;
+ if !(s.eat_if(' ') && s.check_or(false, char::is_alphanumeric)) {
+ break;
+ }
+
+ self.s.eat();
+ }
NodeKind::Text(self.s.eaten_from(start).into())
}