mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Remove unnecessary temporary in tests
We previously didn't support ternaries whose value was unused, so we had an extraneous temporary and console.log call to ensure the value counted as used. We now special-case ternary/conditional expressions which are in an ExpressionStatement to not prune them, so the temporary and log are now unnecessary.
This commit is contained in:
+2
-7
@@ -5,10 +5,7 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
|
||||
: null;
|
||||
console.log(_);
|
||||
props.cond ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo)) : null;
|
||||
mut(x);
|
||||
return x;
|
||||
}
|
||||
@@ -26,9 +23,7 @@ function foo(props) {
|
||||
if (c_0) {
|
||||
x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond ? (([x] = [[]]), x.push(props.foo)) : null;
|
||||
|
||||
console.log(_);
|
||||
props.cond ? (([x] = [[]]), x.push(props.foo)) : null;
|
||||
mut(x);
|
||||
$[0] = props;
|
||||
$[1] = x;
|
||||
|
||||
+1
-4
@@ -1,10 +1,7 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
|
||||
: null;
|
||||
console.log(_);
|
||||
props.cond ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo)) : null;
|
||||
mut(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
+2
-7
@@ -5,10 +5,7 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
|
||||
: null;
|
||||
console.log(_);
|
||||
props.cond ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo)) : null;
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -41,9 +38,7 @@ function foo(props) {
|
||||
t0 = $[3];
|
||||
x = $[4];
|
||||
}
|
||||
const _ = t0;
|
||||
|
||||
console.log(_);
|
||||
t0;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
|
||||
: null;
|
||||
console.log(_);
|
||||
props.cond ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo)) : null;
|
||||
return x;
|
||||
}
|
||||
|
||||
+2
-4
@@ -5,8 +5,7 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
console.log(_);
|
||||
props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
mut(x);
|
||||
return x;
|
||||
}
|
||||
@@ -24,8 +23,7 @@ function foo(props) {
|
||||
if (c_0) {
|
||||
x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond ? ((x = []), x.push(props.foo)) : null;
|
||||
console.log(_);
|
||||
props.cond ? ((x = []), x.push(props.foo)) : null;
|
||||
mut(x);
|
||||
$[0] = props;
|
||||
$[1] = x;
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
console.log(_);
|
||||
props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
mut(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
console.log(_);
|
||||
props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -39,8 +38,7 @@ function foo(props) {
|
||||
t0 = $[3];
|
||||
x = $[4];
|
||||
}
|
||||
const _ = t0;
|
||||
console.log(_);
|
||||
t0;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
console.log(_);
|
||||
props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
|
||||
return x;
|
||||
}
|
||||
|
||||
+2
-6
@@ -5,10 +5,9 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
props.cond
|
||||
? ((x = {}), (x = []), x.push(props.foo))
|
||||
: ((x = []), (x = []), x.push(props.bar));
|
||||
console.log(_);
|
||||
mut(x);
|
||||
return x;
|
||||
}
|
||||
@@ -26,10 +25,7 @@ function foo(props) {
|
||||
if (c_0) {
|
||||
x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
? ((x = []), x.push(props.foo))
|
||||
: ((x = []), x.push(props.bar));
|
||||
console.log(_);
|
||||
props.cond ? ((x = []), x.push(props.foo)) : ((x = []), x.push(props.bar));
|
||||
mut(x);
|
||||
$[0] = props;
|
||||
$[1] = x;
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
props.cond
|
||||
? ((x = {}), (x = []), x.push(props.foo))
|
||||
: ((x = []), (x = []), x.push(props.bar));
|
||||
console.log(_);
|
||||
mut(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
+2
-4
@@ -5,10 +5,9 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
props.cond
|
||||
? ((x = {}), (x = []), x.push(props.foo))
|
||||
: ((x = []), (x = []), x.push(props.bar));
|
||||
console.log(_);
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -43,8 +42,7 @@ function foo(props) {
|
||||
t0 = $[3];
|
||||
x = $[4];
|
||||
}
|
||||
const _ = t0;
|
||||
console.log(_);
|
||||
t0;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
function foo(props) {
|
||||
let x = [];
|
||||
x.push(props.bar);
|
||||
const _ = props.cond
|
||||
props.cond
|
||||
? ((x = {}), (x = []), x.push(props.foo))
|
||||
: ((x = []), (x = []), x.push(props.bar));
|
||||
console.log(_);
|
||||
return x;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user