Skip to content

Commit f93bd00

Browse files
committed
Hoist to_uppercase out of the loop
1 parent d502eda commit f93bd00

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_span/src/lev_distance.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ pub fn find_best_match_for_name(
5656
dist: Option<usize>,
5757
) -> Option<Symbol> {
5858
let lookup = lookup.as_str();
59+
let lookup_uppercase = lookup.to_uppercase();
5960
let max_dist = dist.unwrap_or_else(|| cmp::max(lookup.len(), 3) / 3);
6061

6162
// Priority of matches:
6263
// 1. Exact case insensitive match
6364
// 2. Levenshtein distance match
6465
// 3. Sorted word match
6566
if let Some(case_insensitive_match) =
66-
name_vec.iter().find(|candidate| candidate.as_str().to_uppercase() == lookup.to_uppercase())
67+
name_vec.iter().find(|candidate| candidate.as_str().to_uppercase() == lookup_uppercase)
6768
{
6869
return Some(*case_insensitive_match);
6970
}

0 commit comments

Comments
 (0)