-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix(es/codegen): Fix codegen of large numeric literals #9226
Conversation
|
CodSpeed Performance ReportMerging #9226 will not alter performanceComparing Summary
|
crates/swc_ecma_transforms_optimization/src/simplify/expr/tests.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swc-bump:
- swc_core
- swc_ecma_codegen
} else { | ||
match &num.raw { | ||
Some(raw) => { | ||
if raw.len() > 2 && self.cfg.target < EsVersion::Es2015 && { | ||
let slice = &raw.as_bytes()[..2]; | ||
slice == b"0b" || slice == b"0o" || slice == b"0B" || slice == b"0O" | ||
} { | ||
value = num.value.to_string(); | ||
self.wr.write_str_lit(DUMMY_SP, &value)?; | ||
if num.value.is_infinite() && num.raw.is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this logic duplicate of the logic above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
part is same but else part isn't. And I can't move the if part above this match as this part is only needed for first branch of the match and not for others and they don't use .value
directly instead performs operations to raw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
swc-bump:
- swc_core
- swc_ecma_codegen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
Description:
This PR moves the infinite check below the raw number check
Related issue:
Infinity
/-Infinity
instead of remaining as they are. #9223