Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented transform-remove-undefined plugin. #197

Merged
merged 13 commits into from
Nov 8, 2016

Conversation

shinew
Copy link
Contributor

@shinew shinew commented Oct 18, 2016

Removes the 'void 0' rval for let-/var-assignments.

name: "transform-void-to-nothing",
visitor: {
VariableDeclaration({node: {kind: kind, declarations: declarations}}) {
if (kind !== "const") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe early return to avoid already heavy nesting?

const v0 = require("../../babel-helper-is-void-0/src");

module.exports = function({ types: t }) {
// "var a = void 0;" -> "var a;"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not safe in loops FYI. e.g.

for (var i = 0; i < 2; i++){
    var a = void 0;

    console.log(a);
    a = i;
}

should print

undefined
undefined

not

undefined
0

VariableDeclaration({node: {kind: kind, declarations: declarations}}) {
if (kind !== "const") {
for (const declaration of declarations) {
if (isVoid0(declaration.init)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just check for undefined value. void 0 is just one representation of that value so no need to limit ourselves here (or expect other plugins to kick in before).

I think we should also account for other places, not just declarations. return undefined is currently not transformed to just return.

There's also call expressions foo(x) where we can confidently determine that x is undefined. The only issue here is that removing argument has a side-effect — arguments.length is no longer the same. That would have to be marked as an unsafe transform I guess.

/cc @hzoo @danez

Copy link
Member

@kangax kangax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline

@shinew
Copy link
Contributor Author

shinew commented Oct 19, 2016

I updated the plugin to capture simplify all let declarations, and var declarations that satisfy:

  • are in functions
  • not in loops
  • not referenced before they are declared

This is so that the var foo = undefined is used for only declaration, not for resetting the value of foo.

Also simplified function return values iff they evaluate to undefined.

Removes the 'void 0' rval for let-/var-assignments.
@kangax
Copy link
Member

kangax commented Oct 19, 2016

LGTM but /cc'ing @hzoo @loganfsmyth @danez for sanity check

},
Identifier(path) {
// potential optimization: only store ids that are lvals of assignments.
seenIds.add(path.node.name);
Copy link
Member

@boopathi boopathi Oct 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it also consider this as seen ?

let a = 1;
{
  let a = undefined;
}

?

});

it("should remove undefined return value", () => {
const source = `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...
  ...
      const source = unpad(`
        ...
      `);

This is how all other tests are aligned.

return seenIds.has(id.node.name);
}
let hasReference = false;
id.traverse({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for non simple declarations, you have getBindingIdentifiers() to get the binding identifiers. .traverse is probably not the best idea.

name: "remove-undefined-if-possible",
visitor: {
FunctionParent(path) {
removeUndefinedAssignments(path, t);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this creates 2 more levels of traverse for some paths, can you run this with scripts/plugin-timing if this is taking too much time ?

Copy link
Contributor Author

@shinew shinew Oct 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the timing script after adding this to the preset list:

for file in ./scripts/fixtures/*.js; do
echo $file
./scripts/plugin-timing.js $file
done

./scripts/fixtures/backbone.js

pluginAlias time(ms) # visits time/visit(ms)
minify-simplify 174.445 5669 0.031
minify-mangle-names 88.821 1 88.821
minify-constant-folding 71.037 12515 0.006
remove-undefined-if-possible 67.165 459 0.146
minify-dead-code-elimination 66.802 1 66.802
minify-guarded-expressions 18.205 808 0.023
internal.shadowFunctions 12.601 6406 0.002
foreign$14 11.361 265 0.043
minify-type-constructors 10.955 822 0.013
minify-infinity 7.723 5453 0.001
foreign$15 6.950 5453 0.001
foreign$10 6.535 2024 0.003
foreign$12 3.333 738 0.005
foreign$11 1.797 209 0.009
minify-flip-comparisons 1.457 265 0.005
foreign$13 0.953 236 0.004
internal.blockHoist 0.776 288 0.003
minify-replace 0.153 1 0.153

./scripts/fixtures/flot.js

pluginAlias time(ms) # visits time/visit(ms)
minify-dead-code-elimination 119.034 1 119.034
minify-simplify 89.467 1182 0.076
minify-constant-folding 47.764 6162 0.008
minify-mangle-names 32.701 1 32.701
remove-undefined-if-possible 23.108 54 0.428
minify-guarded-expressions 8.493 180 0.047
internal.shadowFunctions 6.262 2713 0.002
foreign$15 3.823 2713 0.001
minify-infinity 3.684 2713 0.001
minify-type-constructors 2.568 315 0.008
foreign$12 2.458 504 0.005
foreign$10 2.278 1130 0.002
minify-flip-comparisons 1.714 461 0.004
foreign$14 0.819 461 0.002
foreign$11 0.606 61 0.010
foreign$13 0.363 113 0.003
internal.blockHoist 0.278 50 0.006
minify-replace 0.147 1 0.147

./scripts/fixtures/jquery.js

pluginAlias time(ms) # visits time/visit(ms)
minify-simplify 2379.277 54019 0.044
minify-constant-folding 687.636 124589 0.006
minify-mangle-names 645.566 1 645.566
remove-undefined-if-possible 486.537 3746 0.130
minify-guarded-expressions 218.809 11556 0.019
minify-dead-code-elimination 193.202 1 193.202
internal.shadowFunctions 89.802 58084 0.002
minify-infinity 88.526 56758 0.002
foreign$15 87.342 56758 0.002
minify-type-constructors 68.566 7615 0.009
foreign$14 42.466 4852 0.009
foreign$10 29.695 17269 0.002
foreign$12 19.914 9339 0.002
minify-flip-comparisons 18.298 4852 0.004
internal.blockHoist 5.210 2495 0.002
foreign$13 3.870 1336 0.003
foreign$11 3.486 877 0.004
minify-replace 0.298 1 0.298

./scripts/fixtures/react.js

pluginAlias time(ms) # visits time/visit(ms)
minify-simplify 747.820 31213 0.024
minify-mangle-names 480.056 1 480.056
minify-constant-folding 422.067 65514 0.006
minify-dead-code-elimination 410.427 1 410.427
remove-undefined-if-possible 300.603 2157 0.139
minify-guarded-expressions 83.892 3534 0.024
internal.shadowFunctions 52.667 31267 0.002
minify-infinity 48.516 30538 0.002
foreign$15 47.769 30538 0.002
minify-type-constructors 39.374 4199 0.009
foreign$14 33.705 2254 0.015
foreign$12 26.349 7659 0.003
foreign$10 13.478 7812 0.002
foreign$11 8.993 1240 0.007
minify-flip-comparisons 7.981 2254 0.004
foreign$13 7.097 2816 0.003
internal.blockHoist 3.541 1510 0.002
minify-replace 0.151 1 0.151

break;
}
path.node.declarations.forEach((declarator, index) => {
const declaratorPath = path.get("declarations")[index];
Copy link
Member

@boopathi boopathi Oct 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous.

Since you need declarationPath, you can simply do const declarations = path.get("declarations") and just iterate over it, each item will be a declarationPath

case "const":
break;
case "let":
path.node.declarations.forEach((declarator, index) => {
Copy link
Member

@boopathi boopathi Oct 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you need declarationPath, you can simply do const declarations = path.get("declarations") and just iterate over it, each item will be a declarationPath

@boopathi
Copy link
Member

Shouldn't this be a part of DCE ? Is it required to be a separate plugin ?

@kangax
Copy link
Member

kangax commented Oct 20, 2016

I guess it could be part of DCE but I don't know where we want to draw the line between stuffing everything of this nature there or making it more granular.

- used t.getBindingIdentifiers
- changed from forEach to for-loop
- added tests
@kangax
Copy link
Member

kangax commented Oct 21, 2016

486ms on jQuery... yeah, I would say this is a bit too much. We're likely doing unnecessary work. I wonder if merging this into DCE could allow us to utilize DCE's existing traversal/analysis so that we don't have to repeat it all again in another plugin?

/cc @boopathi

@kangax
Copy link
Member

kangax commented Oct 23, 2016

@shinew could you please look into optimizing this? Either by reducing traversal or by integrating into DCE.

@kangax kangax added this to the 0.0.7 milestone Oct 23, 2016
@boopathi
Copy link
Member

I'm not sure if adding how much benefit we get by merging this in DCE. But should try that too - as DCE is a separate and a single pass.

I think you can avoid path.traverse completely by using the information already present. You're using traverse to capture usages of var (and relying on the fact that babel traverses in order). You can use a binding's constantViolations that give you the same information without extra traversals and merge into one visitor.

@kangax
Copy link
Member

kangax commented Oct 25, 2016

@shinew how do the benchmark numbers look now?

@shinew
Copy link
Contributor Author

shinew commented Oct 25, 2016

Sorry it took a while. New benchmarks:

## ./scripts/fixtures/backbone.js
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               241.097  5669     0.043         
minify-mangle-names           113.507  1        113.507       
minify-constant-folding       106.346  12556    0.008         
minify-dead-code-elimination  73.360   1        73.360        
**remove-undefined-if-possible  34.148   6429     0.005**         
minify-guarded-expressions    28.387   808      0.035         
internal.shadowFunctions      17.224   6410     0.003         
minify-type-constructors      12.056   822      0.015         
foreign$16                    10.466   5457     0.002         
minify-infinity               9.747    5457     0.002         
foreign$10                    8.646    2024     0.004         
foreign$15                    7.228    265      0.027         
foreign$12                    4.292    734      0.006         
foreign$11                    2.040    209      0.010         
minify-flip-comparisons       1.992    265      0.008         
foreign$13                    1.150    236      0.005         
internal.blockHoist           0.835    288      0.003         
transform-regexp-constructors 0.555    12       0.046         
minify-replace                0.368    1        0.368         
## ./scripts/fixtures/flot.js
pluginAlias                  time(ms) # visits time/visit(ms)
minify-dead-code-elimination 147.849  1        147.849       
minify-simplify              120.801  1182     0.102         
minify-constant-folding      58.723   6162     0.010         
minify-mangle-names          41.259   1        41.259        
minify-guarded-expressions   12.921   180      0.072         
**remove-undefined-if-possible 12.571   2898     0.004**         
internal.shadowFunctions     5.642    2713     0.002         
foreign$10                   5.069    1130     0.004         
minify-infinity              5.006    2713     0.002         
foreign$16                   4.501    2713     0.002         
minify-type-constructors     3.801    315      0.012         
minify-flip-comparisons      2.523    461      0.005         
foreign$12                   2.281    504      0.005         
foreign$15                   1.003    461      0.002         
foreign$11                   0.810    61       0.013         
foreign$13                   0.423    113      0.004         
internal.blockHoist          0.331    50       0.007         
minify-replace               0.283    1        0.283         
## ./scripts/fixtures/jquery.js
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               2889.617 54019    0.053         
minify-constant-folding       868.176  124182   0.007         
minify-mangle-names           788.845  1        788.845       
minify-guarded-expressions    291.169  11556    0.025         
**remove-undefined-if-possible  271.457  64462    0.004**         
minify-dead-code-elimination  245.046  1        245.046       
internal.shadowFunctions      119.843  57994    0.002         
foreign$16                    119.098  56668    0.002         
minify-infinity               106.865  56668    0.002         
minify-type-constructors      82.721   7592     0.011         
foreign$15                    53.199   4719     0.011         
foreign$10                    34.254   17269    0.002         
foreign$12                    24.017   9238     0.003         
minify-flip-comparisons       18.812   4719     0.004         
internal.blockHoist           9.597    2495     0.004         
foreign$13                    7.662    1336     0.006         
transform-regexp-constructors 5.796    109      0.053         
foreign$11                    5.360    877      0.006         
minify-replace                0.200    1        0.200         
## ./scripts/fixtures/react.js
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               857.623  31213    0.027         
minify-mangle-names           649.043  1        649.043       
minify-constant-folding       528.512  65786    0.008         
minify-dead-code-elimination  499.859  1        499.859       
**remove-undefined-if-possible  191.719  35543    0.005**         
minify-guarded-expressions    104.189  3534     0.029         
internal.shadowFunctions      52.038   31325    0.002         
foreign$16                    50.870   30596    0.002         
minify-infinity               47.076   30596    0.002         
minify-type-constructors      47.074   4199     0.011         
foreign$15                    36.741   2254     0.016         
foreign$12                    25.403   7601     0.003         
foreign$10                    16.597   7812     0.002         
foreign$11                    15.712   1240     0.013         
foreign$13                    10.196   2816     0.004         
minify-flip-comparisons       9.848    2254     0.004         
internal.blockHoist           5.691    1510     0.004         
transform-regexp-constructors 0.351    77       0.005         
minify-replace                0.236    1        0.236

@shinew
Copy link
Contributor Author

shinew commented Oct 25, 2016

I'm not sure constantViolations helps, since for vars, we want to detect usages of the variable before it is declared, and there's no good way of determining if a node comes before another, AFAIK.

@shinew
Copy link
Contributor Author

shinew commented Oct 25, 2016

I think I just realized a mistake in the capturing that makes optimizing vars in functions unsafe:

function foo() {
  (() => {
    t = 0;
  })();
  var t = undefined;
}

In the above case, t cannot be optimized, even though it is not used in foo's scope before it is declared.

If we just drop support for var declarations (or just use constantViolations), this plugin won't need to keep the id references and it will be a ton faster.

@shinew
Copy link
Contributor Author

shinew commented Oct 25, 2016

Updated timings:

**./scripts/fixtures/backbone.js**
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               204.082  5669     0.036         
minify-mangle-names           106.944  1        106.944       
minify-constant-folding       85.452   12556    0.007         
minify-dead-code-elimination  60.986   1        60.986        
**remove-undefined-if-possible  26.650   6339     0.004**         
minify-guarded-expressions    22.787   808      0.028         
internal.shadowFunctions      13.987   6410     0.002         
foreign$16                    11.462   5457     0.002         
minify-type-constructors      9.599    822      0.012         
minify-infinity               8.560    5457     0.002         
foreign$15                    5.864    265      0.022         
foreign$10                    4.243    2024     0.002         
foreign$12                    3.192    734      0.004         
foreign$11                    1.760    209      0.008         
minify-flip-comparisons       1.741    265      0.007         
foreign$13                    0.862    236      0.004         
internal.blockHoist           0.781    288      0.003         
transform-regexp-constructors 0.507    12       0.042         
minify-replace                0.171    1        0.171         
**./scripts/fixtures/flot.js**
pluginAlias                  time(ms) # visits time/visit(ms)
minify-dead-code-elimination 130.785  1        130.785       
minify-simplify              110.263  1182     0.093         
minify-constant-folding      50.019   6162     0.008         
minify-mangle-names          40.197   1        40.197        
**remove-undefined-if-possible 10.132   2862     0.004**         
minify-infinity              9.801    2713     0.004         
minify-guarded-expressions   8.644    180      0.048         
foreign$16                   4.634    2713     0.002         
internal.shadowFunctions     4.408    2713     0.002         
minify-type-constructors     3.035    315      0.010         
minify-flip-comparisons      2.797    461      0.006         
foreign$10                   2.783    1130     0.002         
foreign$12                   2.503    504      0.005         
foreign$15                   1.119    461      0.002         
foreign$11                   0.719    61       0.012         
foreign$13                   0.377    113      0.003         
internal.blockHoist          0.313    50       0.006         
minify-replace               0.178    1        0.178         
**./scripts/fixtures/jquery.js**
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               2544.450 54019    0.047         
minify-constant-folding       760.060  124182   0.006         
minify-mangle-names           752.757  1        752.757       
minify-guarded-expressions    282.243  11556    0.024         
minify-dead-code-elimination  223.285  1        223.285       
**remove-undefined-if-possible  196.775  62994    0.003**         
internal.shadowFunctions      100.756  57994    0.002         
foreign$16                    97.173   56668    0.002         
minify-infinity               92.420   56668    0.002         
minify-type-constructors      72.576   7592     0.010         
foreign$15                    49.689   4719     0.011         
foreign$10                    30.683   17269    0.002         
foreign$12                    21.791   9238     0.002         
minify-flip-comparisons       16.315   4719     0.003         
internal.blockHoist           5.294    2495     0.002         
transform-regexp-constructors 4.809    109      0.044         
foreign$13                    4.742    1336     0.004         
foreign$11                    4.460    877      0.005         
minify-replace                0.206    1        0.206         
**./scripts/fixtures/react.js**
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               796.903  31213    0.026         
minify-mangle-names           622.988  1        622.988       
minify-constant-folding       490.707  65786    0.007         
minify-dead-code-elimination  454.490  1        454.490       
**remove-undefined-if-possible  108.134  35007    0.003**         
minify-guarded-expressions    105.448  3534     0.030         
internal.shadowFunctions      58.788   31325    0.002         
foreign$16                    48.508   30596    0.002         
minify-infinity               46.933   30596    0.002         
minify-type-constructors      43.936   4199     0.010         
foreign$15                    33.376   2254     0.015         
foreign$12                    23.299   7601     0.003         
foreign$10                    16.111   7812     0.002         
minify-flip-comparisons       11.229   2254     0.005         
foreign$11                    10.681   1240     0.009         
foreign$13                    6.826    2816     0.002         
internal.blockHoist           3.543    1510     0.002         
transform-regexp-constructors 0.331    77       0.004         
minify-replace                0.193    1        0.193

@kangax
Copy link
Member

kangax commented Oct 26, 2016

Time looks much better. @boopathi anything else before we merge it?

@boopathi
Copy link
Member

I'll go through and try it out today.

Can we have the name changed to

  • babel-plugin-minify-undefined or
  • babel-plugin-transform-remove-undefined (like transform-remove-console)

?

@kangax
Copy link
Member

kangax commented Oct 26, 2016

I like babel-plugin-transform-remove-undefined

function removeRvalIfUndefined(declaratorPath) {
const rval = declaratorPath.get("init")
.evaluate();
if (rval.confident === true && rval.value === undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be pure.

var x = void console.log("hi");
var y = void foo();

shouldn't be evaluated to undefined and be removed.


function removeRvalIfUndefined(declaratorPath) {
const rval = declaratorPath.get("init")
.evaluate();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you push evaluate to the same line. It's not really long to be added to a separate line.

ReturnStatement(path) {
if (path.node.argument !== null) {
const rval = path.get("argument")
.evaluate();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. Can you push evaluate to the same line as previous one?

if (path.node.argument !== null) {
const rval = path.get("argument")
.evaluate();
if (rval.confident === true && rval.value === undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably requires isPure check here too for

return void console.log("asdf");

var { a: aa, b: bb } = undefined;
}`);
expect(transform(source)).toBe(source);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test cases for

  • void foo()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't convert

function foo() {
  var x = void 0;
  function bar() {
    var x = void 0;
    function baz() {
      var x = void 0;
    }
  }
}

functionNesting++;
},
exit() {
functionNesting--;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you're using this only to check global ? you can use this information to check if different nested function scopes have same variable name and then solve -

function foo() {
  var x = void 0;
  function bar() {
    var x = void 0; // this is not removed now
  }
}

@boopathi
Copy link
Member

Added a few comments inline and those are outdated due to rename.

@shinew
Copy link
Contributor Author

shinew commented Oct 26, 2016

Quick question: when I call exp.isPure() on node.argument or node.init, it returns false even for undefined. What should I do to fix that?

@boopathi
Copy link
Member

@shinew http://astexplorer.net/#/fT7AjgoWqp . That is indeed weird. Not sure. @hzoo bug in babel or am I missing something ?

@boopathi
Copy link
Member

@shinew I just edited your comments with benchmarks to details/summary view.

@shinew
Copy link
Contributor Author

shinew commented Oct 26, 2016

Good points. There's also a concern for a case like:

function foo() {
  bar();
  var x = undefined;
  console.log(x);
  function bar() {
    x = 3;
  }
}

In which case we don't want to remove = undefined (and the cumulative-identifier approach wouldn't work, since the definition of bar appears later). I'm not currently sure what the best approach to solve this case is, unless we hoist every function to the top first.

There's no way we can visit every identifier. Instead, figure out which
constant violations hamper the minification.

Oh, and some test cases. Those should probably be cleaned up. 😁
@kangax kangax modified the milestone: 0.0.7 Oct 27, 2016
@boopathi
Copy link
Member

It's definitely looking better. Thanks @shinew & @jridgewell . I'll try it out ...

@shinew
Copy link
Contributor Author

shinew commented Oct 31, 2016

Updated timings:

**./scripts/fixtures/backbone.js**
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               184.907  5695     0.032         
minify-mangle-names           92.835   1        92.835        
minify-constant-folding       80.994   12663    0.006         
minify-dead-code-elimination  57.145   1        57.145        
minify-guarded-expressions    19.958   824      0.024         
internal.shadowFunctions      12.996   6465     0.002         
foreign$17                    12.975   5504     0.002         
minify-infinity               11.159   5504     0.002         
minify-type-constructors      9.907    831      0.012         
_transform-remove-undefined    8.603    455      0.019_         
foreign$16                    6.055    267      0.023         
foreign$10                    3.673    2041     0.002         
foreign$12                    3.199    736      0.004         
minify-numeric-literals       1.828    307      0.006         
minify-flip-comparisons       1.619    267      0.006         
foreign$11                    1.539    209      0.007         
foreign$13                    0.799    236      0.003         
internal.blockHoist           0.636    288      0.002         
minify-replace                0.530    1        0.530         
transform-regexp-constructors 0.354    12       0.030         
**./scripts/fixtures/flot.js**
pluginAlias                  time(ms) # visits time/visit(ms)
minify-dead-code-elimination 116.025  1        116.025       
minify-simplify              96.169   1182     0.081         
minify-constant-folding      45.831   6165     0.007         
minify-mangle-names          36.987   1        36.987        
minify-guarded-expressions   8.054    180      0.045         
minify-infinity              4.189    2713     0.002         
foreign$17                   3.747    2713     0.001         
_transform-remove-undefined   3.721    81       0.046_         
internal.shadowFunctions     3.539    2713     0.001         
foreign$10                   3.296    1130     0.003         
minify-numeric-literals      2.917    379      0.008         
minify-type-constructors     2.915    315      0.009         
foreign$12                   1.998    504      0.004         
minify-flip-comparisons      1.825    461      0.004         
foreign$16                   0.996    461      0.002         
foreign$11                   0.589    61       0.010         
foreign$13                   0.449    113      0.004         
internal.blockHoist          0.271    50       0.005         
minify-replace               0.172    1        0.172         
**./scripts/fixtures/jquery.js**
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               2069.071 54081    0.038         
minify-constant-folding       668.053  124276   0.005         
minify-mangle-names           646.490  1        646.490       
minify-guarded-expressions    218.957  11562    0.019         
minify-dead-code-elimination  201.449  1        201.449       
internal.shadowFunctions      93.811   58035    0.002         
minify-infinity               82.267   56703    0.001         
foreign$17                    82.020   56703    0.001         
minify-type-constructors      69.348   7600     0.009         
_transform-remove-undefined    48.090   2921     0.016_         
foreign$16                    38.746   4718     0.008         
foreign$10                    26.844   17286    0.002         
minify-numeric-literals       20.449   4311     0.005         
foreign$12                    19.286   9247     0.002         
minify-flip-comparisons       13.737   4718     0.003         
transform-regexp-constructors 5.097    109      0.047         
internal.blockHoist           4.433    2497     0.002         
foreign$13                    3.921    1336     0.003         
foreign$11                    3.548    878      0.004         
minify-replace                0.192    1        0.192         
./scripts/fixtures/react.js
pluginAlias                   time(ms) # visits time/visit(ms)
minify-simplify               698.859  31291    0.022         
minify-mangle-names           598.227  1        598.227       
minify-dead-code-elimination  439.037  1        439.037       
minify-constant-folding       429.159  65906    0.007         
minify-guarded-expressions    89.827   3534     0.025         
minify-infinity               52.861   30641    0.002         
_transform-remove-undefined    48.300   2386     0.020_         
minify-type-constructors      43.500   4208     0.010         
foreign$17                    42.700   30641    0.001         
internal.shadowFunctions      42.437   31368    0.001         
foreign$16                    29.875   2255     0.013         
foreign$12                    20.223   7616     0.003         
foreign$10                    11.226   7828     0.001         
minify-numeric-literals       10.933   2939     0.004         
foreign$11                    8.657    1240     0.007         
minify-flip-comparisons       7.809    2255     0.003         
foreign$13                    6.096    2816     0.002         
internal.blockHoist           2.908    1511     0.002         
transform-regexp-constructors 0.311    77       0.004         
minify-replace                0.187    1        0.187         
**./scripts/fixtures/three.js**
pluginAlias                   time(ms)  # visits time/visit(ms)
minify-simplify               10081.044 88829    0.113         
minify-mangle-names           3197.181  1        3197.181      
minify-constant-folding       1434.629  253686   0.006         
minify-dead-code-elimination  788.394   1        788.394       
internal.shadowFunctions      209.345   121478   0.002         
minify-infinity               189.798   112462   0.002         
minify-guarded-expressions    183.066   7526     0.024         
foreign$17                    182.065   112433   0.002         
_transform-remove-undefined    121.397   7183     0.017_         
minify-type-constructors      112.999   11773    0.010         
foreign$16                    105.486   16149    0.007         
foreign$10                    75.876    40050    0.002         
minify-numeric-literals       55.059    12773    0.004         
minify-flip-comparisons       43.230    16149    0.003         
foreign$12                    43.005    17430    0.002         
foreign$11                    20.310    2651     0.008         
internal.blockHoist           7.378     3821     0.002         
foreign$13                    6.246     2872     0.002         
transform-regexp-constructors 3.560     1493     0.002         
minify-replace                0.180     1        0.180

@boopathi boopathi added the Tag: New Feature Pull Request adding a new feature label Oct 31, 2016
@shinew shinew changed the title Implemented transform-void-to-nothing plugin. Implemented transform-remove-undefined plugin. Nov 2, 2016
@kangax
Copy link
Member

kangax commented Nov 3, 2016

@boopathi Did you have a chance to look at it? Anything else we need?

@boopathi
Copy link
Member

boopathi commented Nov 3, 2016

Not yet ... It looks good. will try it locally.

expect(transform(source)).toBe(expected);
});

it("should remove ...", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be more descriptive? or just make this instead of the previous test?

@boopathi boopathi merged commit 37b639e into babel:master Nov 8, 2016
@shinew shinew deleted the transform-void-to-nothing branch November 8, 2016 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tag: New Feature Pull Request adding a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants