Skip to content

Commit bf525e7

Browse files
committed
perf: borrow owner_filename in build-import-analysis AddDeps (#9874)
`AddDeps` is constructed once per import, and `owner_filename: chunk.filename.to_string()` allocated an identical `String` on every iteration. `owner_filename` is only used for a `&str` equality check, so make the field a `&'a str` borrowing `chunk.filename` and drop the per-import allocation. No behavior change.
1 parent 318db73 commit bf525e7

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

crates/rolldown_plugin_vite_build_import_analysis/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl Plugin for ViteBuildImportAnalysisPlugin {
265265
s: &mut s,
266266
ctx,
267267
deps: &mut deps,
268-
owner_filename: chunk.filename.to_string(),
268+
owner_filename: chunk.filename.as_str(),
269269
analyzed: FxHashSet::default(),
270270
has_removed_pure_css_chunks: &mut has_removed_pure_css_chunks,
271271
expr_range: import.start..import.end,

crates/rolldown_plugin_vite_build_import_analysis/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct AddDeps<'a, 'b> {
1212
pub s: &'a mut MagicString<'b>,
1313
pub ctx: &'a PluginContext,
1414
pub deps: &'a mut FxHashSet<String>,
15-
pub owner_filename: String,
15+
pub owner_filename: &'a str,
1616
pub analyzed: FxHashSet<String>,
1717
pub has_removed_pure_css_chunks: &'a mut bool,
1818
pub expr_range: std::ops::Range<usize>,

0 commit comments

Comments
 (0)