Skip to content

Commit b78241d

Browse files
authored
Rollup merge of rust-lang#145152 - xizheyin:detect-confusion-type, r=lqd
Use `to_ascii_lowercase` 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
2 parents 87475a9 + a8b0f75 commit b78241d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3546,7 +3546,7 @@ pub fn detect_confusion_type(sm: &SourceMap, suggested: &str, sp: Span) -> Confu
35463546

35473547
for (f, s) in iter::zip(found.chars(), suggested.chars()) {
35483548
if f != s {
3549-
if f.to_lowercase().to_string() == s.to_lowercase().to_string() {
3549+
if f.to_ascii_lowercase() == s.to_ascii_lowercase() {
35503550
// Check for case differences (any character that differs only in case)
35513551
if ascii_confusables.contains(&f) || ascii_confusables.contains(&s) {
35523552
has_case_diff = true;

0 commit comments

Comments
 (0)