introduce reduce_vars#1301
introduce reduce_vars#1301alexlamsl wants to merge 7 commits intomishoo:masterfrom alexlamsl:reduce_vars
Conversation
|
PR looks good. Didn't see any obvious issues. I agree Could you add some negative tests exercising all the cases where |
|
Could you please document the new option as well? |
|
@kzc thanks for the quick review, will get onto more tests and documentation now. BTW, I find this case of var A = 1;
(function() {
console.log(A - 2);
})();becomes: (function() {
console.log(-1);
})();Evaluation to |
|
It is as intended. Google Closure transforms that example into |
|
@kzc I see - thanks for the clarification. I have left out any global/top-level variables with Added tests and documentation, PTAL. |
I see there's a I appreciate that operators like |
I wouldn't be concerned with that. If any such variables were modified externally then the |
|
Added tests for |
test/compress/reduce_vars.js
Outdated
| console.log(a + b); | ||
| console.log(b + c); | ||
| // TODO: as "modified" is determined in "figure_out_scope", | ||
| // even "passes" would improve this any further |
|
LGTM Looks like it'd be a useful feature. |
|
Looking gook but I reviewed the pr from my smartphone and couldn't test it throughoutly. |
|
Just FYI, found one case where |
|
I wouldn't worry about it. That's a variation of the issue observed here: #1194 I have a fix but it needs refinement. |
|
Nice, thanks! Merged as 4761d07 |
With a variable which is only assigned a constant value at initialisation and never gets modified elsewhere, this new flag allows
evaluateto treat occurrence of said variable as constant when performing optimisation.Motivated by minification using
global_defsfor places such as this.