-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
fix(transfomer/using): remove use of child ids #9961
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
d70450f
to
fd4b0c7
Compare
CodSpeed Instrumentation Performance ReportMerging #9961 will not alter performanceComparing Summary
|
crates/oxc_transformer/src/proposals/explicit_resource_management.rs
Outdated
Show resolved
Hide resolved
crates/oxc_transformer/src/proposals/explicit_resource_management.rs
Outdated
Show resolved
Hide resolved
fd4b0c7
to
9391d23
Compare
088e6a4
to
20ec38e
Compare
9391d23
to
3cfc9f1
Compare
3cfc9f1
to
f76a83b
Compare
f76a83b
to
5973bbd
Compare
20ec38e
to
4c2e111
Compare
5973bbd
to
7dffe96
Compare
7dffe96
to
3cdc653
Compare
4c2e111
to
4eaf781
Compare
3cdc653
to
1c6f363
Compare
1c6f363
to
fe95aeb
Compare
4eaf781
to
2c53a72
Compare
fe95aeb
to
34ddbd7
Compare
crates/oxc_semantic/src/scoping.rs
Outdated
@@ -677,6 +677,12 @@ impl Scoping { | |||
}); | |||
} | |||
|
|||
pub fn remove_child_scope(&mut self, scope_id: ScopeId, child_scope_ids: ScopeId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn remove_child_scope(&mut self, scope_id: ScopeId, child_scope_ids: ScopeId) { | |
pub fn remove_child_scope(&mut self, scope_id: ScopeId, child_scope_id: ScopeId) { |
crates/oxc_semantic/src/scoping.rs
Outdated
self.cell.with_dependent_mut(|_allocator, cell| { | ||
cell.scope_child_ids[scope_id.index()].retain(|scope_id| *scope_id != child_scope_ids); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was trying to say in previous comment is that this can be more efficient than remove_child_scopes
, because you're only removing a single ID.
let child_ids = &mut cell.scope_child_ids[scope_id.index()];
let index = child_ids.iter().position(|&scope_id| scope_id == child_scope_id).unwrap();
child_ids.swap_remove(index);
Note that retain
shifts up all following entries in the Vec
(slow if there's lots of them), whereas swap_remove
just moves 1 entry (same cheap cost, no matter how many entries in the Vec
). And position
will only search until it finds 1st match, whereas retain
will carry on searching all the entries after its found a match (wasted work in this case because there can be only 1 match).
Warning: The unwrap()
will panic if the ScopeId
isn't found. That means this method must not be called unless the option to record child scope IDs is enabled. Method needs a comment to that effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh i see, thanks for explaining
fn create_try_stmt( | ||
body: BlockStatement<'a>, | ||
catch: ArenaBox<'a, CatchClause<'a>>, | ||
finally: ArenaBox<'a, BlockStatement<'a>>, | ||
ctx: &TraverseCtx<'a>, | ||
) -> Statement<'a> { | ||
ctx.ast.statement_try(SPAN, body, Some(catch), Some(finally)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think more logic could be moved into this method - like generating the CatchClause
and finally
BlockStatement
too. Unless I'm missing something, that logic looks identical across all the call sites too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah you're right. when i origannally looked, i thought there'd end up being a ton of args, but since the catch/finalizer are basically have the same args, it's not bad
34ddbd7
to
021f76c
Compare
fixes #9744