From bd0ae6569fd81f9f53d66b1c696e5394a0fa2bc2 Mon Sep 17 00:00:00 2001 From: kzc Date: Wed, 28 Oct 2015 17:51:46 -0400 Subject: [PATCH] `return undefined` optimization no longer uses `return_void_0` option --- lib/compress.js | 7 +- test/compress/return_undefined.js | 143 +----------------------------- 2 files changed, 3 insertions(+), 147 deletions(-) diff --git a/lib/compress.js b/lib/compress.js index ebe7e957..50353fe0 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -65,7 +65,6 @@ function Compressor(options, false_by_default) { keep_fnames : false, hoist_vars : false, if_return : !false_by_default, - return_void_0 : !false_by_default, join_vars : !false_by_default, cascade : !false_by_default, side_effects : !false_by_default, @@ -2521,10 +2520,8 @@ merge(Compressor.prototype, { OPT(AST_RegExp, literals_in_boolean_context); OPT(AST_Return, function(self, compressor){ - if (compressor.option("return_void_0")) { - if (self.value instanceof AST_Undefined) { - self.value = null; - } + if (self.value instanceof AST_Undefined) { + self.value = null; } return self; }); diff --git a/test/compress/return_undefined.js b/test/compress/return_undefined.js index b1195a72..9662aa51 100644 --- a/test/compress/return_undefined.js +++ b/test/compress/return_undefined.js @@ -1,6 +1,5 @@ -return_void_0_true: { +return_undefined: { options = { - return_void_0 : true, sequences : false, if_return : true, evaluate : true, @@ -123,143 +122,3 @@ return_void_0_true: { } } } - -return_void_0_false: { - options = { - return_void_0 : false, - sequences : false, - if_return : true, - evaluate : true, - dead_code : true, - conditionals : true, - comparisons : true, - booleans : true, - unused : true, - side_effects : true, - properties : true, - drop_debugger : true, - loops : true, - hoist_funs : true, - keep_fargs : true, - keep_fnames : false, - hoist_vars : true, - join_vars : true, - cascade : true, - negate_iife : true - }; - input: { - function f0() { - } - function f1() { - return undefined; - } - function f2() { - return void 0; - } - function f3() { - return void 123; - } - function f4() { - return; - } - function f5(a, b) { - console.log(a, b); - baz(a); - return; - } - function f6(a, b) { - console.log(a, b); - if (a) { - foo(b); - baz(a); - return a + b; - } - return undefined; - } - function f7(a, b) { - console.log(a, b); - if (a) { - foo(b); - baz(a); - return void 0; - } - return a + b; - } - function f8(a, b) { - foo(a); - bar(b); - return void 0; - } - function f9(a, b) { - foo(a); - bar(b); - return undefined; - } - function f10() { - return false; - } - function f11() { - return null; - } - function f12() { - return 0; - } - } - expect: { - function f0() { - } - function f1() { - return void 0; - } - function f2() { - return void 0; - } - function f3() { - return void 0; - } - function f4() { - } - function f5(a, b) { - console.log(a, b); - baz(a); - } - function f6(a, b) { - console.log(a, b); - if (a) { - foo(b); - baz(a); - return a + b; - } - return void 0; - } - function f7(a, b) { - console.log(a, b); - if (a) { - foo(b); - baz(a); - return void 0; - } - return a + b; - } - function f8(a, b) { - foo(a); - bar(b); - return void 0; - } - function f9(a, b) { - foo(a); - bar(b); - return void 0; - } - function f10() { - return !1; - } - function f11() { - return null; - } - function f12() { - return 0; - } - } -} - -- 2.34.1