-c sequences=N suboptimal at N expression cutoff

N = 2:
  a;
  b;
  c;
  d;
was:
  a, b;
  c;
  d;
now:
  a, b;
  c, d;

fixes #1455
closes #1457
This commit is contained in:
alexlamsl
2017-02-18 19:07:03 +08:00
parent ae4db00991
commit f584ca8d07
2 changed files with 48 additions and 1 deletions

View File

@@ -749,7 +749,10 @@ merge(Compressor.prototype, {
seq = []; seq = [];
}; };
statements.forEach(function(stat){ statements.forEach(function(stat){
if (stat instanceof AST_SimpleStatement && seqLength(seq) < compressor.sequences_limit) { if (stat instanceof AST_SimpleStatement) {
if (seqLength(seq) >= compressor.sequences_limit) {
push_seq();
}
seq.push(stat.body); seq.push(stat.body);
} else { } else {
push_seq(); push_seq();

View File

@@ -169,3 +169,47 @@ for_sequences: {
for (y = 5; false;); for (y = 5; false;);
} }
} }
limit_1: {
options = {
sequences: 3,
};
input: {
a;
b;
c;
d;
e;
f;
g;
h;
i;
j;
k;
}
expect: {
a, b, c;
d, e, f;
g, h, i;
j, k;
}
}
limit_2: {
options = {
sequences: 3,
};
input: {
a, b;
c, d;
e, f;
g, h;
i, j;
k;
}
expect: {
a, b, c, d;
e, f, g, h;
i, j, k;
}
}