[Pkg-javascript-commits] [uglifyjs] 184/190: Allow sequences maximum length to be user configurable.

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:25 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit b7ef7840f3f0ab2bec09bec4d4b8a8bb8d50dc78
Author: kzc <zaxxon2011 at gmail.com>
Date:   Sun Jun 26 17:16:02 2016 -0400

    Allow sequences maximum length to be user configurable.
---
 README.md       | 7 ++++++-
 lib/compress.js | 6 ++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 792767d..287c481 100644
--- a/README.md
+++ b/README.md
@@ -291,7 +291,12 @@ you can pass a comma-separated list of options.  Options are in the form
 `foo=bar`, or just `foo` (the latter implies a boolean option that you want
 to set `true`; it's effectively a shortcut for `foo=true`).
 
-- `sequences` -- join consecutive simple statements using the comma operator
+- `sequences` (default: true) -- join consecutive simple statements using the
+  comma operator.  May be set to a positive integer to specify the maximum number
+  of consecutive comma sequences that will be generated. If this option is set to
+  `true` then the default sequences limit is `2000`. Set option to `false` or `0`
+  to disable. On rare occasions the default sequences limit leads to very slow
+  compress times in which case a value of `20` or less is recommended.
 
 - `properties` -- rewrite property access using the dot notation, for
   example `foo["bar"] → foo.bar`
diff --git a/lib/compress.js b/lib/compress.js
index 22d6bf1..6a534c3 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -79,6 +79,8 @@ function Compressor(options, false_by_default) {
         global_defs   : {},
         passes        : 1,
     }, true);
+    var sequences = this.options["sequences"];
+    this.sequences_limit = sequences == 1 ? 2000 : sequences | 0;
     this.warnings_produced = {};
 };
 
@@ -266,7 +268,7 @@ merge(Compressor.prototype, {
             if (compressor.option("if_return")) {
                 statements = handle_if_return(statements, compressor);
             }
-            if (compressor.option("sequences")) {
+            if (compressor.sequences_limit > 0) {
                 statements = sequencesize(statements, compressor);
             }
             if (compressor.option("join_vars")) {
@@ -721,7 +723,7 @@ merge(Compressor.prototype, {
                 seq = [];
             };
             statements.forEach(function(stat){
-                if (stat instanceof AST_SimpleStatement && seqLength(seq) < 2000) {
+                if (stat instanceof AST_SimpleStatement && seqLength(seq) < compressor.sequences_limit) {
                     seq.push(stat.body);
                 } else {
                     push_seq();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list