Mihai Bazon
037199bfe2
Actually let's move away those monsters from the evaluate function
...
ev() should do a single thing — evaluate constant expressions. if that's
not possible, just return the original node. it's not the best place for
partial evaluation there, instead doing it in the compress functions.
2013-09-22 15:00:42 +03:00
Mihai Bazon
583fac0a0f
More dirty handling of [ ... ].join() in unsafe mode
...
Close #300
2013-09-22 13:14:42 +03:00
Dan Wolff
e8158279ff
Evaluate [...].join() if possible: minor bugfix
...
Follow-up to 78e98d2 .
2013-09-22 11:34:30 +03:00
Mihai Bazon
78e98d2611
When unsafe is set, evaluate [...].join() if possible
...
Close #298
2013-09-19 18:20:45 +03:00
Dan Wolff
8d14efe818
Concatenate strings also on the right-hand side of an expression that cannot be evaluated. Fix #126
...
E.g. converts:
a+'Hello'+'World'
to
a+'HelloWorld'
2013-09-19 13:03:03 +03:00
Mihai Bazon
85b527ba3d
Disallow continue referring to a non-IterationStatement. Fix #287
...
Simplifies handling of labels (their definition/references can be easily
figured out at parse time, no need to do it in `figure_out_scope`).
2013-09-02 19:36:16 +03:00
Mihai Bazon
ed80b4a534
Move support for negate_iife in the compressor, rather than code generator
...
(the code generator doesn't maintain enough context to know whether
the return value is important or discarded)
Fixes #272
2013-08-20 17:45:52 +03:00
Michael Ficarra
d9ad3c7cbf
fixes #259 : don't unnecessarily quote object properties when --screw-ie8
2013-08-18 19:45:06 -05:00
Mihai Bazon
4c4dc2137c
Don't drop unused setter argument.
...
Fix #257
2013-08-07 12:04:58 +03:00
Mihai Bazon
964d5b9aa4
Don't pretend to evaluate lambdas
...
Fix #255
2013-08-04 21:44:17 +03:00
Mihai Bazon
41c627379c
Reverting "added option for dropping unused params"
...
Revert "added option for dropping unused params"
(turns out we already had the `unused` option for this.)
This reverts commit e54df2226f .
2013-07-25 18:08:36 +03:00
Dusan Bartos
e54df2226f
added option for dropping unused params
2013-07-25 17:37:47 +03:00
Mihai Bazon
02a84385a0
Don't swap binary ops when "use asm" is in effect.
...
Refs #167
2013-06-07 12:52:09 +03:00
Mihai Bazon
caa8896a8a
Only compress code in new Function if all arguments are strings.
2013-05-14 18:36:31 +03:00
Mihai Bazon
f64539fb76
Compress code passed to new Function if it's a constant.
...
Only for `--unsafe`.
Close #203
2013-05-14 10:47:06 +03:00
Mihai Bazon
d56ebd7d7b
Fix a["1_1"]
...
Close #204
2013-05-14 10:42:34 +03:00
Mihai Bazon
a6ed2c84ac
Better fix for equality of typeof ... against "undefined"
2013-05-08 16:22:48 +03:00
Justin Lau
a1958aad56
Fixed typeof undefined optimization and updated related test case to
...
accomodates the sort behaviour changes made in commit
mishoo/UglifyJS2@aebafad41e .
Signed-off-by: Justin Lau <justin@tclau.com >
2013-05-08 16:22:48 +03:00
Justin Lau
9af2bbffde
Fixed dot properties not optimizing unicode identifiers. Signed-off-by: Justin Lau <justin@tclau.com>
2013-05-07 14:20:19 +03:00
Justin Lau
1e3bc0caa0
Fixed dot property issue with invlid identifier names.
...
Signed-off-by: Justin Lau <justin@tclau.com >
2013-05-05 22:27:43 +08:00
Michael Ficarra
5af144522a
fixes #189 : use dotted member access when --screw-ie8 option given
2013-04-20 15:11:05 -05:00
Roman Bataev
4b818056cf
Fix typeof evaluation for regex and function
2013-04-03 22:34:38 -04:00
Mihai Bazon
e4b078cff7
Disable unsafe by default
...
Close #147
2013-03-11 00:04:31 +02:00
Mihai Bazon
aebafad41e
Fix reordering comparisons
...
Close #143
2013-03-04 10:06:01 +02:00
Mihai Bazon
dac6efb43d
Drop last default: if it's the last branch and empty
...
Close #141
2013-03-01 13:12:03 +02:00
Mihai Bazon
8880f4824c
Compress boolean constants after evaluation
...
Close #137
2013-03-01 10:26:06 +02:00
Mihai Bazon
3a591c43fe
Fix compressing do {...} while (false)
...
It's not safe to transform it to {...} because the body might contain
`break`. The solution could be more elaborate (detect if body contains
`break`) but I don't think it's worth the trouble.
Close #129
2013-02-19 18:12:19 +02:00
Mihai Bazon
f36e4e9a78
Give up evaluating (unary-prefix '-' 0)
...
Close #117
------
JS, WHY YOU SUCK SO BADLY? ;-(
2013-02-06 11:51:09 +02:00
Mihai Bazon
9e8ba27dcd
Fix handling of constants
...
Close #113
2013-02-06 11:15:31 +02:00
Richard Gibson
522566ea80
Fix #105 : property comparison to undefined is not always safe
2013-01-23 23:52:04 -05:00
Mihai Bazon
f0909bdc8f
Handle String() with no arguments.
...
Fix #91
2013-01-17 11:01:38 +02:00
Mihai Bazon
31c4a37e37
Optimize new Array(1, 2, 3) → [1, 2, 3]
...
Close #74
2012-12-21 21:04:35 +02:00
Mihai Bazon
16430acc1f
small improvement on merging assignments into hoisted vars
2012-12-05 13:14:49 +02:00
Mihai Bazon
320c110b33
When hoisting variables, try to merge in assignments that follow.
2012-12-05 12:30:25 +02:00
Mihai Bazon
5cc90db7d0
Don't messup compressor stack while optimizing Switch
...
Fix #59
2012-11-30 11:16:09 +02:00
Mihai Bazon
4f555e2232
fix for https://github.com/mishoo/UglifyJS/issues/474
2012-11-23 10:20:00 +02:00
Mihai Bazon
0d3fd2ef30
retain (1,eval) as is when it's the expression of an AST_Call
...
otherwise we change the meaning of eval from global to lexical.
2012-11-17 12:05:31 +02:00
Mihai Bazon
bdfcbf496b
better solution for the last test in constant switch folding
2012-11-14 12:21:43 +02:00
Mihai Bazon
dba8da4800
optimize constant switch blocks
...
ref. mishoo/UglifyJS#441
2012-11-14 12:06:07 +02:00
Mihai Bazon
60c0f40250
Merge branch 'optimize_concat' of https://github.com/rvanvelzen/UglifyJS2 into rvanvelzen-optimize_concat
2012-11-13 14:38:55 +02:00
Mihai Bazon
e02771a5f2
don't change order in binary expressions if both operands have side effects
2012-11-13 14:32:07 +02:00
Richard van Velzen
f96f796f71
Add simple optimization for empty-string concats.
...
ref. #43
2012-11-12 15:41:03 +01:00
Mihai Bazon
53355bdb24
fix invalid AST produced by dropping unused variable
...
close #44
2012-11-12 13:23:57 +02:00
Dan Wolff
b49230ab8d
convert x.toString() to ""+x instead of x+""
...
In some places this can save one byte in whitespace, e.g. after return.
Example:
function f(arg) {
// return""+arg - no space between return and ""
return arg.toString();
}
2012-11-11 15:53:34 +02:00
Mihai Bazon
1e5e13ed81
AST_LabelRef no longer inherits from AST_SymbolRef
2012-11-08 15:39:14 +02:00
Mihai Bazon
1a5fd3e052
optimization for if/break as first statement in a loop body
...
for(...; x; ...) if (y) break; → for(...; x&&!y; ...);
similarly for `while` and some combinations (i.e. the `break` appears in the
`else` clause, etc.)
2012-11-08 11:43:14 +02:00
Mihai Bazon
ffccb233e5
convert while into for
2012-11-05 16:01:20 +02:00
Mihai Bazon
fba0c1aafe
minor
2012-11-05 16:01:09 +02:00
Mihai Bazon
774f2ded94
minor optimization
...
for `==` or `!=` against a constant, prefer to display the constant first.
should help a bit after gzip, i.e.:
typeof foo=="undefined"
^^^^^^ ^^^^^^^^^^^^^
vs:
"undefined"==typeof foo
^^^^^^^^^^^^^^^^^^^ (longer sequence that could repeat)
idea stolen from closure.
2012-11-05 13:13:06 +02:00
Mihai Bazon
8413787efc
use a Dictionary object instead of plain object for hashes
...
to mitigate the `__proto__` issue
related to #30
2012-11-02 10:58:45 +02:00