mishoo/UglifyJS2 — pull request #550 by TalAter (2014-09-13 17:29:19+00:00)
Title: New optimizations for two types of conditional statements

#### tl;dr
````
x = foo ? foo : bar --> x = foo || bar
x = y ? false : true --> x = !y
x = y ? true : false --> x = !!y
````

#### 1. Optimize conditionals where the consequent and alternative are false and true booleans

For example:
````javascript
if (y) {
return true;
} else {
return false;
}
// will become return !!y;

if (y) {
x = true;
} else {
x = false;
}
// will become x=!!y;

if (y) {
x = false;
} else {
x = true;
}
// will become x=!y;

x = y ? false : true;
// will become x=!y;
````

Compressed and evaluated:
````javascript
//Before this change:
return y?true:false;x=y?true:false;x=y?false:true;x=y?false:true;
//After this change:
return !!y;x=!!y;x=!y;x=!y;
````

#### 2. Optimize conditionals where the condition and consequent are equivalent

For example:
````javascript
if (foo) {
x = foo;
} else {
x = bar;
}
// will become x=foo || bar;

x = foo ? foo : bar();
// will become x = foo || bar();
````

Compressed and evaluated:
````javascript
//Before this change:
x=foo?foo:bar;x=foo?foo:bar();
//After this change:
x=foo||bar;x=foo||bar();
````