Skip to content

Commit 23e86f6

Browse files
authored
Rollup merge of #114351 - ttsugriy:sort-by-words, r=fee1-dead
[rustc_span][perf] Remove unnecessary string joins and allocs. Comparing vectors of string parts yields the same result but avoids unnecessary `join` and potential allocation for resulting `String`. This code is cold so it's unlikely to have any measurable impact, but considering but since it's also simpler, why not? :)
2 parents 5054e41 + f74eee2 commit 23e86f6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_span/src/edit_distance.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ fn find_match_by_sorted_words(iter_names: &[Symbol], lookup: &str) -> Option<Sym
248248
})
249249
}
250250

251-
fn sort_by_words(name: &str) -> String {
251+
fn sort_by_words(name: &str) -> Vec<&str> {
252252
let mut split_words: Vec<&str> = name.split('_').collect();
253253
// We are sorting primitive &strs and can use unstable sort here.
254254
split_words.sort_unstable();
255-
split_words.join("_")
255+
split_words
256256
}

0 commit comments

Comments
 (0)