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

perf(es/minifier): Speed up merge_sequences_in_exprs by caching computation #9843

Merged
merged 10 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
invalidate
  • Loading branch information
CPunisher committed Jan 6, 2025
commit 6a92f9bded584463ecc8fdc63259e970e9c03c2b
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ impl Optimizer<'_> {
&& self.merge_sequential_expr(a, b)?
{
changed = true;
merge_seq_cache.invalidate(b_idx);
break;
}
}
Expand All @@ -925,13 +926,15 @@ impl Optimizer<'_> {
&& self.merge_sequential_expr(a, b)?
{
changed = true;
merge_seq_cache.invalidate(b_idx);
break;
}
}
Mergable::FnDecl(..) => continue,
Mergable::Drop => {
if self.drop_mergable_seq(a)? {
changed = true;
merge_seq_cache.invalidate(b_idx);
break;
}
}
Expand Down Expand Up @@ -998,7 +1001,6 @@ impl Optimizer<'_> {
}

if let Some(id) = a.id() {
// TODO(kdy1): Optimize
if merge_seq_cache.is_ident_used_by(&id, &**e2, b_idx) {
break;
}
Expand Down Expand Up @@ -2726,6 +2728,10 @@ impl MergeSequenceCache {
idents.contains(ident)
}

fn invalidate(&mut self, node_id: usize) {
self.ident_usage_cache[node_id] = None;
}

fn is_top_retain(&mut self, optimizer: &Optimizer, a: &Mergable, node_id: usize) -> bool {
*self.top_retain_cache[node_id].get_or_insert_with(|| {
if let Mergable::Drop = a {
Expand Down
Loading