Skip to content

Commit

Permalink
Small performance optimization for language order function
Browse files Browse the repository at this point in the history
  • Loading branch information
kellpossible committed Apr 1, 2024
1 parent 5cff57d commit e61ed5e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/i18n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn order_languages<T>(
language_order: &[unic_langid::LanguageIdentifier],
eq: impl Fn(&T, &unic_langid::LanguageIdentifier) -> bool,
) -> Vec<T> {
let mut ordered = Vec::new();
let mut ordered = Vec::with_capacity(unordered.len());
for l in language_order {
if let Some(i) = unordered.iter().position(|t| eq(t, l)) {
ordered.push(unordered.remove(i));
Expand Down

0 comments on commit e61ed5e

Please sign in to comment.