scanner: small optimisation of the ident_name hot loop

pull/12360/head
Delyan Angelov 2021-10-29 16:18:34 +03:00
parent b86c79329b
commit 3d800b12e8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 4 additions and 3 deletions

View File

@ -222,10 +222,11 @@ fn (mut s Scanner) ident_name() string {
s.pos++
for s.pos < s.text.len {
c := s.text[s.pos]
if !(util.is_name_char(c) || c.is_digit()) {
break
if (c >= `a` && c <= `z`) || (c >= `A` && c <= `Z`) || (c >= `0` && c <= `9`) || c == `_` {
s.pos++
continue
}
s.pos++
break
}
name := s.text[start..s.pos]
s.pos--