Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize swc_ecma_transforms_base::Helpers #9222

Closed
kdy1 opened this issue Jul 12, 2024 · 0 comments · Fixed by #9321
Closed

Optimize swc_ecma_transforms_base::Helpers #9222

kdy1 opened this issue Jul 12, 2024 · 0 comments · Fixed by #9321

Comments

@kdy1
Copy link
Member

kdy1 commented Jul 12, 2024

Describe the feature

struct Inner {
$( $name: AtomicBool, )*
}

Currently, we use AtomicBool for tracking used helpers, but we can use bool instead. We can merge by performing || on each fields while passing it to another thread.

We also need to patch code at

HELPERS.with(|helpers| {
HANDLER.with(|handler| {
nodes
.into_par_iter()
.map(|node| {
GLOBALS.set(globals, || {
HELPERS.set(helpers, || {
HANDLER.set(handler, || {
let mut visitor = Parallel::create(&*self);
let node = node.fold_with(&mut visitor);
(visitor, node)
})
})
})
})
.fold(
|| (Parallel::create(&*self), vec![]),
|mut a, b| {
Parallel::merge(&mut a.0, b.0);
a.1.push(b.1);
a
},
)
.reduce(
|| (Parallel::create(&*self), vec![]),
|mut a, b| {
Parallel::merge(&mut a.0, b.0);
a.1.extend(b.1);
a
},
)
})
})
});

Babel plugin or link to the feature description

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant