perf(transformer/typescript): reduce scope_id() calls#18097
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. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR implements a micro-optimization in the TypeScript enum transformation code by eliminating a redundant method call. The scope_id() method has a cost (including a panicking branch), and since the scope ID was already retrieved and stored in a local variable earlier in the function, the code now reuses that cached value instead of making the same call again.
Changes:
- Replace redundant
decl.body.scope_id()call with the existingfunc_scope_idvariable
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
Tiny optimization. Calling `EnumBody::scope_id` has a cost (a panicking branch). We already called it earlier in this function and have the scope ID in a local var. Use that value, rather then calling `scope_id()` again.
8e94bb7 to
4a312a0
Compare
d1fa554 to
837edf6
Compare

Tiny optimization. Calling
EnumBody::scope_idhas a cost (a panicking branch). We already called it earlier in this function and have the scope ID in a local var. Use that value, rather then callingscope_id()again.