Skip to content

feat(minifier): fold simple literals passed to unary +#8943

Merged
graphite-app[bot] merged 1 commit intomainfrom
02-06-feat_minifier_fold_simple_literals_passed_to_unary_
Feb 7, 2025
Merged

feat(minifier): fold simple literals passed to unary +#8943
graphite-app[bot] merged 1 commit intomainfrom
02-06-feat_minifier_fold_simple_literals_passed_to_unary_

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Feb 7, 2025

Added support for folding +[] and +/any-regex/.

+ uses ToNumber and ToNumber uses ToPrimitive for objects. ToPrimitive for [] returns "", for /any-regex/ it returns "/any-regex/".

References

Copy link
Member Author

sapphi-red commented Feb 7, 2025


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 7, 2025

CodSpeed Performance Report

Merging #8943 will not alter performance

Comparing 02-06-feat_minifier_fold_simple_literals_passed_to_unary_ (14462be) with main (2c4f004)

Summary

✅ 33 untouched benchmarks

@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 7, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 02-06-fix_minifier_fix_comparison_of_strings_with_unicode_characters branch from 8b64a88 to b5a7785 Compare February 7, 2025 13:31
graphite-app bot pushed a commit that referenced this pull request Feb 7, 2025
Added support for folding `+[]` and `+/any-regex/`.

`+` uses `ToNumber` and `ToNumber` uses `ToPrimitive` for objects. `ToPrimitive` for `[]` returns `""`, for `/any-regex/` it returns `"/any-regex/"`.

**References**
- [Spec of unary `+`](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-unary-plus-operator-runtime-semantics-evaluation)
- [Spec of `ToPrimitive`](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-toprimitive)
@graphite-app graphite-app bot force-pushed the 02-06-feat_minifier_fold_simple_literals_passed_to_unary_ branch from 2b20341 to 6357a2b Compare February 7, 2025 13:31
Base automatically changed from 02-06-fix_minifier_fix_comparison_of_strings_with_unicode_characters to main February 7, 2025 13:54
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 7, 2025
@sapphi-red sapphi-red force-pushed the 02-06-feat_minifier_fold_simple_literals_passed_to_unary_ branch from 6357a2b to 7ec8a28 Compare February 7, 2025 15:13
Added support for folding `+[]` and `+/any-regex/`.

`+` uses `ToNumber` and `ToNumber` uses `ToPrimitive` for objects. `ToPrimitive` for `[]` returns `""`, for `/any-regex/` it returns `"/any-regex/"`.

**References**
- [Spec of unary `+`](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-unary-plus-operator-runtime-semantics-evaluation)
- [Spec of `ToPrimitive`](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-toprimitive)
@graphite-app graphite-app bot force-pushed the 02-06-feat_minifier_fold_simple_literals_passed_to_unary_ branch from 7ec8a28 to 14462be Compare February 7, 2025 15:36
@graphite-app graphite-app bot merged commit 14462be into main Feb 7, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 02-06-feat_minifier_fold_simple_literals_passed_to_unary_ branch February 7, 2025 15:42
Dunqing pushed a commit that referenced this pull request Feb 10, 2025
Added support for folding `+[]` and `+/any-regex/`.

`+` uses `ToNumber` and `ToNumber` uses `ToPrimitive` for objects. `ToPrimitive` for `[]` returns `""`, for `/any-regex/` it returns `"/any-regex/"`.

**References**
- [Spec of unary `+`](https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-unary-plus-operator-runtime-semantics-evaluation)
- [Spec of `ToPrimitive`](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-toprimitive)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants