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
Mihai Bazon
cf409800be
it's safe to negate expression in !EXP only in boolean context
...
#kendo
2012-11-01 15:49:05 +02:00
Mihai Bazon
18270dd9f3
added unsafe_comps for negating <= with >
...
since it has the potential to break code, let's keep it disabled by default
2012-11-01 15:14:56 +02:00
Mihai Bazon
d4c25c571b
fix compressing UnaryPrefix
...
only try negating the expression if the operator is `!`
#kendo
2012-11-01 13:35:08 +02:00
Mihai Bazon
abe0ebbf02
don't move expressions containing the binary in operator into the for initializer
...
(opera can't parse it)
close #25
2012-10-30 14:50:47 +02:00
Mihai Bazon
70fd2b1f33
fix for if (...) return; else return ...;
...
(it was assumed that the first `return` always contains a value)
close #22
2012-10-24 09:33:32 +03:00
Mihai Bazon
30faaf13ed
more sequence optimizations (lift some sequences above binary/unary expressions so that we can avoid parens)
2012-10-22 11:58:06 +03:00
Mihai Bazon
fc8314e810
minor fix for dropping unused definitions.
...
function f(x, y) {
var g = function() { return h() };
var h = function() { return g() };
return x + y;
}
now compresses to `function f(x, y) { return x + y }`
2012-10-19 12:57:29 +03:00
Mihai Bazon
afb7faa6fa
more optimizations for some break/continue cases
2012-10-18 15:14:57 +03:00
Mihai Bazon
253bd8559b
more small optimizations
...
(unlikely to help for hand-written code)
2012-10-17 21:57:08 +03:00
Mihai Bazon
6a099fba66
define aborts on AST_If: true if both branches abort
2012-10-17 16:17:14 +03:00