Rollup merge of #145152 - xizheyin:detect-confusion-type, r=lqd

Use `eq_ignore_ascii_case` to avoid heap alloc in `detect_confuse_type`

A small optimization has been made, using `to_ascii_lowercase()` instead of `to_lowercase().to_string()`.

r? compiler
This commit is contained in:
Jacob Pratt
2025-08-10 15:43:55 -04:00
committed by GitHub
+1 -1
View File
@@ -3546,7 +3546,7 @@ pub fn detect_confusion_type(sm: &SourceMap, suggested: &str, sp: Span) -> Confu
for (f, s) in iter::zip(found.chars(), suggested.chars()) {
if f != s {
if f.to_lowercase().to_string() == s.to_lowercase().to_string() {
if f.eq_ignore_ascii_case(&s) {
// Check for case differences (any character that differs only in case)
if ascii_confusables.contains(&f) || ascii_confusables.contains(&s) {
has_case_diff = true;