Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(minifier): implement folding charCodeAt string fns #6475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

camc314
Copy link
Collaborator

@camc314 camc314 commented Oct 12, 2024

No description provided.

Copy link

graphite-app bot commented Oct 12, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Collaborator Author

camc314 commented Oct 12, 2024

@github-actions github-actions bot added the A-minifier Area - Minifier label Oct 12, 2024
@camc314 camc314 marked this pull request as ready for review October 12, 2024 12:34
@camc314 camc314 force-pushed the c/10-10-feat_minifier_implement_folding_charat_string_fns branch from 05a79d4 to 273f6f5 Compare October 12, 2024 12:36
@camc314 camc314 force-pushed the c/10-11-feat_minifier_implement_folding_charcodeat_string_fns branch from 5124d0f to 561ec3d Compare October 12, 2024 12:36
Copy link

codspeed-hq bot commented Oct 12, 2024

CodSpeed Performance Report

Merging #6475 will not alter performance

Comparing c/10-11-feat_minifier_implement_folding_charcodeat_string_fns (7d686fc) with main (096e590)

Summary

✅ 29 untouched benchmarks

fold_same("x = 'abcde'.charCodeAt(0, ++z)"); // or (++z, 97)
// START: note the following test cases outputs differ from Google's
fold("x = 'abcde'.charCodeAt()", "x = 97");
fold("x = 'abcde'.charCodeAt(0, ++z)", "x = 97");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not appear correct. z++ is missing.

@Boshen Boshen force-pushed the c/10-10-feat_minifier_implement_folding_charat_string_fns branch from 273f6f5 to 096e590 Compare October 13, 2024 06:41
Base automatically changed from c/10-10-feat_minifier_implement_folding_charat_string_fns to main October 13, 2024 06:46
@Boshen Boshen force-pushed the c/10-11-feat_minifier_implement_folding_charcodeat_string_fns branch from 561ec3d to 7d686fc Compare October 13, 2024 06:46
Copy link
Contributor

@7086cmd 7086cmd left a comment

Choose a reason for hiding this comment

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

I don't have enough time these days, so if things ready, call @Boshen to review and merge.

Comment on lines +167 to +179
let char_at_index: Option<f64> = match call_expr.arguments.first() {
Some(Argument::NumericLiteral(numeric_lit)) => Some(numeric_lit.value),
Some(Argument::UnaryExpression(unary_expr))
if unary_expr.operator == UnaryOperator::UnaryNegation =>
{
let Expression::NumericLiteral(numeric_lit) = &unary_expr.argument else {
return None;
};
Some(-(numeric_lit.value))
}
None => None,
_ => return None,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

        let char_at_index = call_expr.arguments.first().and_then(|idx| ctx.get_number_value(idx))

Similar approches, you don't need to handle it manually.

@Boshen Boshen self-assigned this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-minifier Area - Minifier
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants