Merge 958af035b6 into c8b6f4733d
This commit is contained in:
commit
ca2dadf1d7
|
|
@ -4230,26 +4230,13 @@ merge(Compressor.prototype, {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (init) {
|
if (init) {
|
||||||
var value_length = init.optimize(compressor).print_to_string().length;
|
d.should_replace = has_symbol_ref(fixed) ? function() {
|
||||||
var fn;
|
|
||||||
if (has_symbol_ref(fixed)) {
|
|
||||||
fn = function() {
|
|
||||||
var result = init.optimize(compressor);
|
var result = init.optimize(compressor);
|
||||||
return result === init ? result.clone(true) : result;
|
return result === init ? result.clone(true) : result;
|
||||||
};
|
} : function() {
|
||||||
} else {
|
|
||||||
value_length = Math.min(value_length, fixed.print_to_string().length);
|
|
||||||
fn = function() {
|
|
||||||
var result = best_of_expression(init.optimize(compressor), fixed);
|
var result = best_of_expression(init.optimize(compressor), fixed);
|
||||||
return result === init || result === fixed ? result.clone(true) : result;
|
return result === init || result === fixed ? result.clone(true) : result;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
var name_length = d.name.length;
|
|
||||||
var overhead = 0;
|
|
||||||
if (compressor.option("unused") && !compressor.exposed(d)) {
|
|
||||||
overhead = (name_length + 2 + value_length) / d.references.length;
|
|
||||||
}
|
|
||||||
d.should_replace = value_length <= name_length + overhead ? fn : false;
|
|
||||||
} else {
|
} else {
|
||||||
d.should_replace = false;
|
d.should_replace = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,25 +47,23 @@ collapse_vars_side_effects_1: {
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f1() {
|
function f1() {
|
||||||
var s = "abcdef", i = 2;
|
var i = 2;
|
||||||
console.log.bind(console)(s.charAt(i++), s.charAt(i++), s.charAt(i++), 7);
|
console.log.bind(console)("abcdef".charAt(i++), "abcdef".charAt(i++), "abcdef".charAt(i++), 7);
|
||||||
}
|
}
|
||||||
function f2() {
|
function f2() {
|
||||||
var log = console.log.bind(console),
|
var log = console.log.bind(console),
|
||||||
s = "abcdef",
|
|
||||||
i = 2,
|
i = 2,
|
||||||
x = s.charAt(i++),
|
x = "abcdef".charAt(i++),
|
||||||
y = s.charAt(i++),
|
y = "abcdef".charAt(i++),
|
||||||
z = s.charAt(i++);
|
z = "abcdef".charAt(i++);
|
||||||
log(x, i, y, z, 7);
|
log(x, i, y, z, 7);
|
||||||
}
|
}
|
||||||
function f3() {
|
function f3() {
|
||||||
var s = "abcdef",
|
var i = 2,
|
||||||
i = 2,
|
|
||||||
log = console.log.bind(console),
|
log = console.log.bind(console),
|
||||||
x = s.charAt(i++),
|
x = "abcdef".charAt(i++),
|
||||||
y = s.charAt(i++);
|
y = "abcdef".charAt(i++);
|
||||||
log(x, s.charAt(i++), y, 7);
|
log(x, "abcdef".charAt(i++), y, 7);
|
||||||
}
|
}
|
||||||
function f4() {
|
function f4() {
|
||||||
var i = 10,
|
var i = 10,
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,7 @@ chained_evaluation_2: {
|
||||||
expect: {
|
expect: {
|
||||||
(function() {
|
(function() {
|
||||||
(function() {
|
(function() {
|
||||||
var b = "long piece of string";
|
f("long piece of string").bar = "long piece of string";
|
||||||
f(b).bar = b;
|
|
||||||
})();
|
})();
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user