Skip to content

feat(minifier): merge expressions in for-in statement head#8811

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-31-feat_minifier_merge_expressions_in_for-in_statement_head
Jan 31, 2025
Merged

feat(minifier): merge expressions in for-in statement head#8811
graphite-app[bot] merged 1 commit intomainfrom
01-31-feat_minifier_merge_expressions_in_for-in_statement_head

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Jan 31, 2025

Compress a; for (var b in c) d into for (var b in a, c) d. This is possible when the left hand does not have a sideeffectful initializer. (Initializers on the left hand of for-in is Annex B thing.)

References

  • Spec of ForIn/OfHeadEvaluation: c in the example above is passed as expr to this abstract operation. No side effect exists before Step 3.
  • Spec of the initializer in ForIn: See "The runtime semantics of ForInOfLoopEvaluation in 14.7.5.5 are augmented with the following:" part. Evaluation of Initializer is executed before ForIn/OfHeadEvalution. This is the reason why it cannot be compressed when a sideeffectful initializer exists.

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Jan 31, 2025
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.

@sapphi-red sapphi-red force-pushed the 01-31-feat_minifier_merge_expressions_in_for-in_statement_head branch from de38ca3 to 486f86e Compare January 31, 2025 12:16
@sapphi-red sapphi-red marked this pull request as ready for review January 31, 2025 12:22
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 31, 2025

CodSpeed Performance Report

Merging #8811 will not alter performance

Comparing 01-31-feat_minifier_merge_expressions_in_for-in_statement_head (d9f1d0d) with main (adb8ebd)

Summary

✅ 33 untouched benchmarks

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Jan 31, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 31, 2025

Merge activity

@graphite-app graphite-app bot added 0-merge Merge with Graphite Merge Queue and removed 0-merge Merge with Graphite Merge Queue labels Jan 31, 2025
Compress `a; for (var b in c) d` into `for (var b in a, c) d`. This is possible when the left hand does not have a sideeffectful initializer. (Initializers on the left hand of for-in is Annex B thing.)

**References**
- [Spec of `ForIn/OfHeadEvaluation`](https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-runtime-semantics-forinofheadevaluation): `c` in the example above is passed as `expr` to this abstract operation. No side effect exists before Step 3.
- [Spec of the initializer in ForIn](https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-initializers-in-forin-statement-heads): See "The runtime semantics of ForInOfLoopEvaluation in 14.7.5.5 are augmented with the following:" part. Evaluation of Initializer is executed before `ForIn/OfHeadEvalution`. This is the reason why it cannot be compressed when a sideeffectful initializer exists.
@graphite-app graphite-app bot force-pushed the 01-31-feat_minifier_merge_expressions_in_for-in_statement_head branch from 486f86e to d9f1d0d Compare January 31, 2025 15:31
@graphite-app graphite-app bot merged commit d9f1d0d into main Jan 31, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 01-31-feat_minifier_merge_expressions_in_for-in_statement_head branch January 31, 2025 15:37
@oxc-bot oxc-bot mentioned this pull request Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-minifier Area - Minifier C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant