Skip to content

Commit

Permalink
perf(es/module): Replace find_pat_ids with bound_names for perfor…
Browse files Browse the repository at this point in the history
…mance
  • Loading branch information
magic-akari committed Dec 17, 2024
1 parent fd7401b commit 6ccf61b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions crates/swc_ecma_transforms_module/src/module_decl_strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use swc_common::{
Mark, Span, SyntaxContext,
};
use swc_ecma_ast::*;
use swc_ecma_utils::{find_pat_ids, private_ident, quote_ident, ExprFactory};
use swc_ecma_utils::{private_ident, quote_ident, ExprFactory, PatExt};
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};

use crate::{module_ref_rewriter::ImportMap, SpanCtx};
Expand Down Expand Up @@ -138,11 +138,13 @@ impl VisitMut for ModuleDeclStrip {
}

Decl::Var(v) => {
self.export.extend(
find_pat_ids::<_, Ident>(&v.decls)
.into_iter()
.map(|id| (id.sym.clone(), ExportItem::new((id.span, id.ctxt), id))),
);
v.bound_names(&mut |ident| {
let id = &ident.id;
self.export.insert(
id.sym.clone(),
ExportItem::new((id.span, id.ctxt), id.clone()),
);
});
}
_ => {}
};
Expand Down

0 comments on commit 6ccf61b

Please sign in to comment.