Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Apr 16, 2025

Follow-on after #10418. Pure refactor.

private_field_count is accessed in both the entry and exit phases of the transform, so move that field up to be with the other fields which are in that same category.

Expand the comment which explains how this optimization works.

Also, when reviewing #10418, I had to trace through the logic to make sure that it wasn't possible for decreasing private_field_count on exit to get skipped if is_transform_required is false. Turns out it's not a problem - is_transform_required is always true if class has any private properties/methods. Add comments to clarify that.

Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Apr 16, 2025
@overlookmotel overlookmotel marked this pull request as ready for review April 16, 2025 14:13
@overlookmotel overlookmotel requested a review from Dunqing as a code owner April 16, 2025 14:13
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 16, 2025

CodSpeed Instrumentation Performance Report

Merging #10447 will create unknown performance changes

Comparing 04-16-refactor_transformer_class-properties_re-order_fields_and_expand_comments (3ebd494) with main (25e4c53)

Summary

🆕 36 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 codegen[checker.ts] N/A 22.2 ms N/A
🆕 codegen_sourcemap[checker.ts] N/A 65.2 ms N/A
🆕 formatter[antd.js] N/A 637.3 ms N/A
🆕 formatter[react.development.js] N/A 6.1 ms N/A
🆕 formatter[typescript.js] N/A 813.5 ms N/A
🆕 isolated-declarations[vue-id.ts] N/A 58.4 ms N/A
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 21.4 µs N/A
🆕 lexer[antd.js] N/A 24.8 ms N/A
🆕 lexer[cal.com.tsx] N/A 5.9 ms N/A
🆕 lexer[checker.ts] N/A 14.9 ms N/A
🆕 lexer[pdf.mjs] N/A 3.9 ms N/A
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.7 ms N/A
🆕 linter[cal.com.tsx] N/A 1.2 s N/A
🆕 linter[checker.ts] N/A 3 s N/A
🆕 mangler[antd.js] N/A 15.9 ms N/A
🆕 mangler[react.development.js] N/A 292.9 µs N/A
🆕 mangler[typescript.js] N/A 39.4 ms N/A
🆕 minifier[antd.js] N/A 163.5 ms N/A
🆕 minifier[react.development.js] N/A 1.8 ms N/A
🆕 minifier[typescript.js] N/A 287.7 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

By the way, I forgot one thing in my PR: to add a debug_assert_eq!(self.private_field_count, 0) in exit_program or elsewhere to ensure we are correctly handling private_field_count so that we can catch any potential bug related to this in the future if we do a huge refactor in class_properties.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Apr 16, 2025
Copy link
Member Author

overlookmotel commented Apr 16, 2025

Merge activity

…mments (#10447)

Follow-on after #10418. Pure refactor.

`private_field_count` is accessed in both the entry and exit phases of the transform, so move that field up to be with the other fields which are in that same category.

Expand the comment which explains how this optimization works.

Also, when reviewing #10418, I had to trace through the logic to make sure that it wasn't possible for decreasing `private_field_count` on exit to get skipped if `is_transform_required` is `false`. Turns out it's not a problem - `is_transform_required` is always `true` if class has any private properties/methods. Add comments to clarify that.
@graphite-app graphite-app bot force-pushed the 04-16-refactor_transformer_class-properties_re-order_fields_and_expand_comments branch from ae08f67 to 3ebd494 Compare April 16, 2025 16:35
@graphite-app graphite-app bot merged commit 3ebd494 into main Apr 16, 2025
29 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 16, 2025
@graphite-app graphite-app bot deleted the 04-16-refactor_transformer_class-properties_re-order_fields_and_expand_comments branch April 16, 2025 16:44
graphite-app bot pushed a commit that referenced this pull request Apr 17, 2025
…ount` is 0 at end of transform (#10457)

`private_field_count` is incremented when entering a class with private properties/methods and decremented when leaving it. Make sure this is working correctly by ensuring `private_field_count == 0` at the end of the transform.

As suggested in #10447 (review).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants