refactor(transformer/class-properties): simplify to get constructor method only once#10493
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 22, 2025
Conversation
Member
Author
CodSpeed Instrumentation Performance ReportMerging #10493 will not alter performanceComparing Summary
|
ba4f2c6 to
f24f711
Compare
3c055cd to
5ca39af
Compare
This was referenced Apr 18, 2025
graphite-app bot
pushed a commit
that referenced
this pull request
Apr 22, 2025
…instance property initializer (#10492) Move the `instance_inits_scope_id` and `instance_inits_constructor_scope_id` fields from the `ClassProperties` struct to local variables. Using struct-level fields as temporary variables is unnecessary within three function depths, and you also need to consider when to reset the states, otherwise, you may cause a bug due to using previous temporary information. Moreover, I think it also improves a bit readability. NOTE: This is not only a refactor, but also along with #10495 and #10493 to prepare #10491.
overlookmotel
approved these changes
Apr 22, 2025
Member
overlookmotel
left a comment
There was a problem hiding this comment.
Nice! Yes, getting constructor twice was necessary before only to work around the borrow checker. You've solved that problem now.
graphite-app bot
pushed a commit
that referenced
this pull request
Apr 22, 2025
…rs scopes until all instance properties are transformed (#10495) Re-parenting the initializers' scope after all instance properties are transformed, which is preparing for #10493. And rename `transform_instance_initializer` to `reparent_initializers_scope` because the previous name confused me; the implementation only affects scope data. Moreover, there is a drawback to this change. The `reparent_initializers_scope` method now processes initializers that have been transformed, so that it will visit many unrelated AST nodes. See the transformer/pdf.js benchmark, it shows `0.1ms` slower than before. It may not matter; we will get it back in the follow-up changes.
Member
Merge activity
|
f24f711 to
aaa8993
Compare
Member
|
Graphite got confused somehow. I've rebased on main and restacked to fix (non-existent) merge conflicts. Hopefully it'll get merged now. |
aaa8993 to
36ea0af
Compare
36ea0af to
596978b
Compare
overlookmotel
added a commit
that referenced
this pull request
Apr 22, 2025
) Follow-on after #10493. We no longer locate the class constructor here. Remove a comment that says we do.
Boshen
added a commit
that referenced
this pull request
Apr 23, 2025
## [0.66.0] - 2025-04-23 ### Features - 7d5ad7d parser: Report error when `import type { type }` is used (#10528) (camc314) - 6e40fac parser: Report error when `export type { type }` is used (#10524) (camc314) ### Bug Fixes - 43ad4e9 ast: Box `this_param` in `TSCallSignatureDeclaration` (#10558) (Yuji Sugiura) - 8eb3c0a ast/estree: Fix raw deser for `FormalParameter` (#10548) (overlookmotel) - 3ebf220 codegen: Generate missing `type` in `export type {} from 'mod'` (#10539) (Boshen) - f19b287 estree: Add `TSParameterProperty` (#10534) (Yuji Sugiura) - 7284f16 isolated-declarations: Leading comments of `ExportDefaultDeclaration` and `TSExportAssignment` appear in incorrect places (#10559) (Dunqing) - 4c316a5 isolated_declarations: Fix broken snapshot files (#10561) (Boshen) - 84742d8 transformer/module_runner: Fix export default live binding (#10560) (hi-ogawa) - 6c115c7 transformer/module_runner: Fix execution order of re-export (#10362) (hi-ogawa) - b9d84b0 transformer/typescript: Remove `StringLiteral::raw` when rewriting extensions (#10554) (overlookmotel) ### Performance - 6a045c8 codegen: Speed up printing `Directive`s (#10551) (overlookmotel) - 3418ae5 transformer/class-properties: Re-use `InstanceInitializerVisitor` (#10543) (overlookmotel) - 7fcf0ac transformer/typescript: Reduce allocations renaming extensions (#10555) (overlookmotel) ### Documentation - 1a9530c transformer/class-properties: Fix typo (#10542) (overlookmotel) ### Refactor - 7e71282 transformer/class-properties: Correct outdated comment (#10546) (overlookmotel) - 596978b transformer/class-properties: Simplify to get `constructor` method only once (#10493) (Dunqing) - f13fe0a transformer/class-properties: Defer re-parenting initializers scopes until all instance properties are transformed (#10495) (Dunqing) - c83dad6 transformer/class-properties: Streamline handling scope of instance property initializer (#10492) (Dunqing) ### Styling - e10dfc8 traverse: Remove excess whitespace (#10544) (overlookmotel) ### Testing - 227febf allocator: Ignore a slow doc test (#10521) (Dunqing) - 14bb2be codegen: Add more tests for strings (#10552) (overlookmotel) Co-authored-by: Boshen <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Benefit from #10495, we can move getting
instance_inits_scope_idandinstance_inits_constructor_scope_idpart to after all instance properties transformed. So that we can avoid to getconstructortwice due to borrow checker.