-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Consider replacing some expression instanceof AST_Constant
with expression.is_constant()
across the codebase
#1144
Comments
|
Also is_constant doesn't return Here "num" can be inlined safely into the return (provided it's the only use case):
And now |
is_primitive sounds great! |
After creating #1141, I had an idea that it might not be the only case where such a change is beneficial.
I think mostly it would be good for when there is a constant with one (or more (#1142)) unary prefixes, which, I believe is pretty common because we usually transform
true
to!0
andundefined
tovoid 0
, which makesexpression instanceof AST_Constant
false
.The main issue here is that I don't quite understand why
is_constant()
returnsfalse
forAST_RegExp
:terser/lib/compress/evaluate.js
Line 109 in 540e886
Here's the commit that introduced this: 0610c02
Might just try doing this anyway and just seeing if any tests fail?
And I'd be glad to work on this.
The text was updated successfully, but these errors were encountered: