about summary refs log tree commit diff
path: root/compiler/rustc_ast/src/token.rs
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2025-01-11 12:11:42 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2025-01-11 12:39:44 -0500
commit6f72f13436f4ca1b8ef06307eb0b7479dc9188bf (patch)
treee91673940b093d012b636290134a4e76c6781ae4 /compiler/rustc_ast/src/token.rs
parentfb65a3ee576feab95a632eb062f466d7a0342310 (diff)
downloadrust-6f72f13436f4ca1b8ef06307eb0b7479dc9188bf.tar.gz
rust-6f72f13436f4ca1b8ef06307eb0b7479dc9188bf.zip
Remove allocations from case-insensitive comparison to keywords
Diffstat (limited to 'compiler/rustc_ast/src/token.rs')
-rw-r--r--compiler/rustc_ast/src/token.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs
index f639e785bc4..3b7367d1ee2 100644
--- a/compiler/rustc_ast/src/token.rs
+++ b/compiler/rustc_ast/src/token.rs
@@ -909,7 +909,8 @@ impl Token {
         self.is_keyword(kw)
             || (case == Case::Insensitive
                 && self.is_non_raw_ident_where(|id| {
-                    id.name.as_str().to_lowercase() == kw.as_str().to_lowercase()
+                    // Do an ASCII case-insensitive match, because all keywords are ASCII.
+                    id.name.as_str().eq_ignore_ascii_case(kw.as_str())
                 }))
     }