perf(lexer): only check the first lower case for match_keyword (#913)

This commit is contained in:
Boshen 2023-09-14 23:19:16 +08:00 committed by GitHub
parent a6d8d05cd3
commit f447cf3a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -371,7 +371,7 @@ impl Kind {
pub fn match_keyword(s: &str) -> Self {
let len = s.len();
if len == 1 || len >= 12 {
if len <= 1 || len >= 12 || !s.as_bytes()[0].is_ascii_lowercase() {
return Ident;
}
Self::match_keyword_impl(s)