[Pkg-javascript-commits] [uglifyjs] 135/190: Actually limit sequence length.
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:20 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 b5a7a231f7e9f09cc00e92c970d304d6071f7ac1
Author: Mihai Bazon <mihai.bazon at gmail.com>
Date: Tue Apr 12 14:15:14 2016 +0300
Actually limit sequence length.
Fix #1038
---
lib/ast.js | 7 +++++++
lib/compress.js | 20 ++++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/lib/ast.js b/lib/ast.js
index 2a46183..42506cb 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -633,6 +633,13 @@ var AST_Seq = DEFNODE("Seq", "car cdr", {
p = p.cdr;
}
},
+ len: function() {
+ if (this.cdr instanceof AST_Seq) {
+ return this.cdr.len() + 1;
+ } else {
+ return 2;
+ }
+ },
_walk: function(visitor) {
return visitor._visit(this, function(){
this.car._walk(visitor);
diff --git a/lib/compress.js b/lib/compress.js
index e47be97..153e70f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -673,8 +673,12 @@ merge(Compressor.prototype, {
seq = [];
};
statements.forEach(function(stat){
- if (stat instanceof AST_SimpleStatement && seq.length < 2000) seq.push(stat.body);
- else push_seq(), ret.push(stat);
+ if (stat instanceof AST_SimpleStatement && seqLength(seq) < 2000) {
+ seq.push(stat.body);
+ } else {
+ push_seq();
+ ret.push(stat);
+ }
});
push_seq();
ret = sequencesize_2(ret, compressor);
@@ -682,6 +686,18 @@ merge(Compressor.prototype, {
return ret;
};
+ function seqLength(a) {
+ for (var len = 0, i = 0; i < a.length; ++i) {
+ var stat = a[i];
+ if (stat instanceof AST_Seq) {
+ len += stat.len();
+ } else {
+ len++;
+ }
+ }
+ return len;
+ };
+
function sequencesize_2(statements, compressor) {
function cons_seq(right) {
ret.pop();
--
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