-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
void 0
can be optimized to an unassigned variable
#2585
Comments
I initially thought using an uninitialized variable instead of The issue is that uglify goes out of its way to eliminate unused variables in order to further simplify code. So this proposal would be counter to that.
Off topic: In case anyone reading this ticket thinks that array holes are an alternative to |
This proposed The concerns:
These concerns could be mitigated by only introducing the uninitialized If it were to be implemented it would also need a new compress option to gate it. |
I'd be interested in implementing this change, unless you think it'd be too complicated. Would this be gated by |
@Skalman Sure, go for it. It would be a safe transform but should be gated by some new I made some notes above how I think it should be implemented - after the final |
|
Look at |
The biggest obstacle to implementing this undefined transform is to not spend excessive CPU scanning each and every function for For harmony the undefined transform could conceivably be done for |
(Thanks!)
I agree. Further improvements could be made at a later stage.
It looks like
Yeah, this could be a problem. I believe we only need to check for
This could be implemented at a later stage. Is this where I'd add a call to this new compression? |
If you're looking for an existing
True. If you walk the tree from Yes, you'd invoke this transform at the end of |
Just treat it like a normal |
Bug report or feature request?
Feature request
ES5 or ES6+ input?
ES5
Uglify version (
uglifyjs -V
)uglify-js 3.2.2
JavaScript input
The
uglifyjs
CLI command executed orminify()
options used.Default
JavaScript output or error produced.
This can be further optimized as this:
This saves 5 bytes per each
undefined
usage as long at least one variable was declared in a function scope, at cost of having to use 2 extra bytes forvar
declaration.var
declaration can be inserted in a scope above in event there is a function within a function for extra savings.The text was updated successfully, but these errors were encountered: