Skip to content

Commit b7bc61f

Browse files
committed
refactor: to_string when nessarry
1 parent 7d05bbd commit b7bc61f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,7 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
17601760
let mut best_key = String::new();
17611761
// 2. Let expansionKeys be the list of keys of matchObj containing only a single "*", sorted by the sorting function PATTERN_KEY_COMPARE which orders in descending order of specificity.
17621762
// 3. For each key expansionKey in expansionKeys, do
1763-
for (key, target) in match_obj {
1764-
let expansion_key = key.to_string();
1763+
for (expansion_key, target) in match_obj {
17651764
if expansion_key.starts_with("./") || expansion_key.starts_with('#') {
17661765
// 1. Let patternBase be the substring of expansionKey up to but excluding the first "*" character.
17671766
if let Some((pattern_base, pattern_trailer)) = expansion_key.split_once('*') {
@@ -1779,16 +1778,16 @@ impl<Fs: FileSystem + Send + Sync> ResolverGeneric<Fs> {
17791778
best_target = Some(target);
17801779
// 2. Let patternMatch be the substring of matchKey starting at the index of the length of patternBase up to the length of matchKey minus the length of patternTrailer.
17811780
best_match = &match_key[pattern_base.len()..match_key.len() - pattern_trailer.len()];
1782-
best_key = expansion_key;
1781+
best_key = expansion_key.to_string();
17831782
}
17841783
} else if expansion_key.ends_with('/')
1785-
&& match_key.starts_with(&expansion_key)
1786-
&& Self::pattern_key_compare(&best_key, &expansion_key).is_gt()
1784+
&& match_key.starts_with(&**expansion_key)
1785+
&& Self::pattern_key_compare(&best_key, expansion_key).is_gt()
17871786
{
17881787
// TODO: [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./dist/" in the "exports" field module resolution of the package at xxx/package.json.
17891788
best_target = Some(target);
17901789
best_match = &match_key[expansion_key.len()..];
1791-
best_key.clone_from(&expansion_key);
1790+
best_key = expansion_key.to_string();
17921791
}
17931792
}
17941793
}

0 commit comments

Comments
 (0)