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 · 1 comment · Fixed by #9321
Closed

Optimize swc_ecma_transforms_base::Helpers #9222

kdy1 opened this issue Jul 12, 2024 · 1 comment · 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

@swc-bot
Copy link
Collaborator

swc-bot commented Aug 22, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

2 participants