kzc
3907a5e3b2
Fix warnings for referenced non-hoisted functions.
...
Fixes #1034
Also added `expect_warnings` functionality to test framework.
2016-04-11 18:15:20 +02:00
Mihai Bazon
9317237372
Avoid using inherited hasOwnProperty
...
Fix #1031
2016-04-07 13:16:22 +03:00
kzc
98434258d0
Optimize ternaries with boolean consequent or alternative.
...
Fixes #511
2016-04-02 17:22:12 +02:00
kzc
45ddb9caeb
Speedup unused compress option for already minified code
...
Fixes : #321 #917 #1022
2016-03-28 17:58:50 -04:00
kzc
11b0efdf84
boolean_expression ? true : false --> boolean_expression
2016-02-22 17:59:36 +01:00
kzc
5486b68850
Take operator || precendence into account for AST_If optimization.
...
Fixes #979 .
2016-02-21 12:05:02 -05:00
alexlamsl
6547437725
preserve ThisBinding for side_effects
2016-02-17 19:34:01 +01:00
Richard van Velzen
9662228f6a
Don't compress (0, eval)() to eval()
2016-02-16 19:00:48 +01:00
alexlamsl
31a9b05c96
Preserve ThisBinding in conditionals & collapse_vars
...
Fixes #973
2016-02-16 18:47:49 +01:00
kzc
7c3fee9e31
collapse_vars: avoid replacement across AST_Case nodes to be on safe side even though no issues seen.
2016-01-29 10:35:07 -05:00
kzc
929de2b0de
collapse_vars: fix if/else and ternary operator side effects
2016-01-28 12:17:06 -05:00
kzc
af2472d85e
collapse_vars: fix bug in repeated var defs of same name
2016-01-28 16:48:50 +01:00
kzc
0a38a688f9
fix bug in collapse_vars for right side of "||" and "&&"
2016-01-27 14:18:46 -05:00
kzc
f4c2ea37bf
Collapse single use var definitions
...
Fix #721
2016-01-27 11:48:15 +02:00
Mihai Bazon
fe4e9f9d97
Fix hoisting the var in ForIn
...
Close #913
2016-01-05 13:56:52 +02:00
kzc
774bda13cd
#873 Fix conditionals optimizations with default compress options
2015-11-24 13:27:50 -05:00
Mihai Bazon
7f48d5b33c
Fix endless loop
...
Close #866
2015-11-16 12:08:24 +02:00
Mihai Bazon
b6968b6bd2
Limit max iterations for tighten_body
...
Ref #866
2015-11-16 12:08:24 +02:00
Mihai Bazon
7691bebea5
Rework has_directive
...
It's now available during tree walking, i.e. walker.has_directive("use
asm"), rather than as part of the scope. It's thus no longer necessary
to call `figure_out_scope` before codegen. Added special bits in the
code generator to overcome the fact that it doesn't inherit from
TreeWalker.
Fix #861
2015-11-11 22:15:25 +02:00
kzc
bd0ae6569f
return undefined optimization no longer uses return_void_0 option
2015-10-29 08:19:12 +01:00
kzc
7491d07666
optimize return undefined and return void 0
2015-10-29 08:19:12 +01:00
kzc
593677d2ff
Add proper support for "use asm"; blocks. Disable -c optimization within "use asm"; sections and preserve floating point literals in their original form. Non-asm.js sections are optimized as before. Asm.js sections can still be mangled and minified of whitespace. No special command line flags are required.
2015-10-07 10:00:28 +02:00
Ville Lautanala
5fd12451f9
Control keeping function arguments with a single option
2015-09-14 19:38:45 +02:00
Richard van Velzen
e3bd223dac
Don't change sequences that influence lexical binding in calls
...
Fixes #782
2015-08-25 10:53:35 +02:00
Christopher Chedeau
3ff0b9e0c9
[Fix] --define replaces SymbolRefs in LHS of assignments
...
See #208 for context
2015-08-10 11:22:36 -07:00
thorn0
252fc65558
Advanced way to specify if a function call might have side effects. #400
2015-07-29 14:36:42 +02:00
Mihai Bazon
905b601178
Don't attempt to negate non-boolean AST_Binary
...
Fix #751
2015-07-22 16:55:55 +03:00
Mihai Bazon
63fb2d5a44
Merge pull request #735 from kzc/master
...
optimizations for && and || where left side is constant expression
2015-07-20 09:58:01 +03:00
Mihai Bazon
85a5fc0aeb
Don't drop parens in a * (b * c). Close #744
2015-06-30 10:10:29 +03:00
kzc
f47b2b52a5
operator && and || optimization: add "else" before "if" as intended
2015-06-14 17:44:26 -04:00
kzc
fedb6191a1
optimizations for && and || where left side is constant expression
2015-06-11 23:22:38 -04:00
Mihai Bazon
a5b60217ce
Fix compressing conditionals
...
Only transform foo() ? EXP(x) : EXP(y) into EXP(foo() ? x : y) if EXP has no
side effects.
Fix #710
2015-05-18 13:56:04 +03:00
Mihai Bazon
c3a10c135e
Avoid spurious brackets when dropping unused vars
...
Fix #702
2015-05-04 14:49:17 +03:00
Mihai Bazon
274e1b3dc7
Drop NaN -> 0/0 transformation.
...
Fix #687
2015-04-17 11:26:36 +03:00
Mihai Bazon
18c63ff3d8
Fix compression of conditionals
...
Don't move the condition on the right side of an assignment when
the left side may have side effects.
Fix #677
2015-04-13 17:29:48 +03:00
Mihai Bazon
276b9a31cd
Fix compressing ![foo()]; as a statement
...
need to check whether the literal has any side effects before replacing that
with `false`.
2015-03-23 23:27:00 +02:00
Mihai Bazon
5801fa39e9
[sequencesize] Actually even better:
...
do create the sequence even if the stat list is bigger than 2000 statements,
but limit the sequence itself to 2000 expressions.
Ref #414
2015-03-22 13:02:45 +02:00
Mihai Bazon
f0ab1b02e6
Avoid sequencesize for more than 2000 statements.
...
It hardly saves any bytes for a sequence so long, and it risks blowing the
stack with the recursive Seq functions.
Ref #414
2015-03-22 12:51:15 +02:00
Mihai Bazon
36c28e02fd
Add start/end nodes for NaN/Infinity transformations
2015-03-22 12:50:36 +02:00
Mihai Bazon
ecfd881ac6
Keep unused function arguments by default
...
Discarding unused function arguments affects function.length, which can lead
to some hard to debug issues. This optimization is now done only in "unsafe
mode".
Fix #121
2015-03-20 10:28:51 +02:00
Richard van Velzen
992b6b9fcc
Fix invalid removal of left side in && and || compression
...
See #637 . This does not produce the optimal result, but it does prevent the removal of non-side-effect-free code.
2015-02-11 21:08:41 +01:00
Richard van Velzen
605362f89d
Drop all console statements properly
...
Because the base reference can be an member expression as well, we have to dig a bit deeper to find the leftmost base reference.
Fixes #451
2015-01-31 13:24:44 +01:00
Tal Ater
a1a4c2ada7
Optimize conditionals where the consequent and alternative are both booleans and not equivalent
2015-01-13 18:27:21 +01:00
Richard van Velzen
42ecd42ac0
Replace the correct node when replacing in void sequences
...
Close #611 .
2015-01-12 17:09:34 +01:00
Mihai Bazon
a10f6a96d7
Merge pull request #482 from arty-name/inline-ng-inject
...
added @ngInject support for inline functions
2015-01-11 12:10:42 +02:00
Mihai Bazon
61c233a08e
Fix make_node_from_constant for Regexp-s
...
Close #588
2015-01-07 11:20:04 +02:00
Mihai Bazon
d2d716483a
aborts(AST_If) returns the if node
...
Previously it returned the abort node from the alternative branch. This is
not much use as it can be different from the one in the body
branch (i.e. return vs. throw) and can trick us into issues like #591 .
Fix #591
2015-01-06 14:01:35 +02:00
Mihai Bazon
e1f0747e4c
Support keep_fnames in compressor, and --keep-fnames. #552
...
Passing `--keep-fnames` will enable it both for compressor/mangler, so that
function names will not be dropped (when unused) nor mangled.
2015-01-05 11:03:13 +02:00
Richard van Velzen
f4d36a58c2
Fix #569
...
When no arguments are given to `new Function()`, it should be treated as
a regular anonymous function (http://es5.github.io/#x15.3.2.1 )
2015-01-04 13:37:59 +01:00
Richard van Velzen
c75f5a1fd8
Fix #597
...
NaN and Infinity were replaced in the output generation, instead of
during compression. This could lead to results where `1/0` was inserted
without parens leading to invalid output.
The nodes are replaced in the compression step now, and the output
generation returns their regular names. This should not be a problem,
since they're already only constructed from the original name.
2014-12-31 12:23:00 +01:00