mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Optimize check_keyword_case
.
`to_lowercase` allocates, but `eq_ignore_ascii_case` doesn't. This path is hot enough that this makes a small but noticeable difference in benchmarking.
This commit is contained in:
parent
f7273e0044
commit
99d02fb40f
@ -641,9 +641,10 @@ impl<'a> Parser<'a> {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Do an ASCII case-insensitive match, because all keywords are ASCII.
|
||||
if case == Case::Insensitive
|
||||
&& let Some((ident, IdentIsRaw::No)) = self.token.ident()
|
||||
&& ident.as_str().to_lowercase() == kw.as_str().to_lowercase()
|
||||
&& ident.as_str().eq_ignore_ascii_case(kw.as_str())
|
||||
{
|
||||
true
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user