rename variables for better readability (#1863)

This commit is contained in:
Alex Lam S.L
2017-05-02 20:47:10 +08:00
committed by GitHub
parent bffdc8dca8
commit 5a25d24b56

View File

@@ -3703,7 +3703,7 @@ merge(Compressor.prototype, {
var init = fixed.evaluate(compressor); var init = fixed.evaluate(compressor);
if (init !== fixed) { if (init !== fixed) {
init = make_node_from_constant(init, fixed); init = make_node_from_constant(init, fixed);
var value = init.optimize(compressor).print_to_string().length; var value_length = init.optimize(compressor).print_to_string().length;
var fn; var fn;
if (has_symbol_ref(fixed)) { if (has_symbol_ref(fixed)) {
fn = function() { fn = function() {
@@ -3711,18 +3711,18 @@ merge(Compressor.prototype, {
return result === init ? result.clone(true) : result; return result === init ? result.clone(true) : result;
}; };
} else { } else {
value = Math.min(value, fixed.print_to_string().length); value_length = Math.min(value_length, fixed.print_to_string().length);
fn = function() { 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 = d.name.length; var name_length = d.name.length;
var overhead = 0; var overhead = 0;
if (compressor.option("unused") && (!d.global || compressor.toplevel(d))) { if (compressor.option("unused") && (!d.global || compressor.toplevel(d))) {
overhead = (name + 2 + value) / d.references.length; overhead = (name_length + 2 + value_length) / d.references.length;
} }
d.should_replace = value <= name + overhead ? fn : false; d.should_replace = value_length <= name_length + overhead ? fn : false;
} else { } else {
d.should_replace = false; d.should_replace = false;
} }