Skip to content

Commit 07a6e5b

Browse files
authored
perf(turbopack): let some Clone be conditional in insert_alias_option (vercel#81175)
## What As the title described.
1 parent 5dac448 commit 07a6e5b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

crates/next-core/src/next_import_map.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub async fn get_next_client_import_map(
112112

113113
insert_alias_option(
114114
&mut import_map,
115-
project_path.clone(),
115+
&project_path,
116116
next_config.resolve_alias_options(),
117117
["browser"],
118118
)
@@ -311,7 +311,7 @@ pub async fn get_next_server_import_map(
311311

312312
insert_alias_option(
313313
&mut import_map,
314-
project_path.clone(),
314+
&project_path,
315315
next_config.resolve_alias_options(),
316316
[],
317317
)
@@ -453,7 +453,7 @@ pub async fn get_next_edge_import_map(
453453

454454
insert_alias_option(
455455
&mut import_map,
456-
project_path.clone(),
456+
&project_path,
457457
next_config.resolve_alias_options(),
458458
[],
459459
)
@@ -1149,15 +1149,13 @@ pub async fn get_next_package(context_directory: FileSystemPath) -> Result<Vc<Fi
11491149

11501150
pub async fn insert_alias_option<const N: usize>(
11511151
import_map: &mut ImportMap,
1152-
project_path: FileSystemPath,
1152+
project_path: &FileSystemPath,
11531153
alias_options: Vc<ResolveAliasMap>,
11541154
conditions: [&'static str; N],
11551155
) -> Result<()> {
11561156
let conditions = BTreeMap::from(conditions.map(|c| (c.into(), ConditionValue::Set)));
11571157
for (alias, value) in &alias_options.await? {
1158-
if let Some(mapping) =
1159-
export_value_to_import_mapping(value, &conditions, project_path.clone())
1160-
{
1158+
if let Some(mapping) = export_value_to_import_mapping(value, &conditions, project_path) {
11611159
import_map.insert_alias(alias, mapping);
11621160
}
11631161
}
@@ -1167,7 +1165,7 @@ pub async fn insert_alias_option<const N: usize>(
11671165
fn export_value_to_import_mapping(
11681166
value: &SubpathValue,
11691167
conditions: &BTreeMap<RcStr, ConditionValue>,
1170-
project_path: FileSystemPath,
1168+
project_path: &FileSystemPath,
11711169
) -> Option<ResolvedVc<ImportMapping>> {
11721170
let mut result = Vec::new();
11731171
value.add_results(
@@ -1180,7 +1178,7 @@ fn export_value_to_import_mapping(
11801178
None
11811179
} else {
11821180
Some(if result.len() == 1 {
1183-
ImportMapping::PrimaryAlternative(result[0].0.into(), Some(project_path))
1181+
ImportMapping::PrimaryAlternative(result[0].0.into(), Some(project_path.clone()))
11841182
.resolved_cell()
11851183
} else {
11861184
ImportMapping::Alternatives(

0 commit comments

Comments
 (0)