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

Remove unused fn params #182

Merged
merged 3 commits into from
Oct 13, 2016
Merged

Remove unused fn params #182

merged 3 commits into from
Oct 13, 2016

Conversation

boopathi
Copy link
Member

@boopathi boopathi commented Oct 8, 2016

@boopathi
Copy link
Member Author

boopathi commented Oct 8, 2016

The tests fail right now because I've set the default as to remove unused fn params and haven't modified other tests. Should it be opt-in instead of opt-out ?

@kangax
Copy link
Member

kangax commented Oct 8, 2016

I think keepFnArgs would be better and then we should rename keepFname to keepFnName

@kangax
Copy link
Member

kangax commented Oct 8, 2016

Removing them by default seems fine if we're doing same with names. IMO, if we start getting complains we can change.

@boopathi
Copy link
Member Author

boopathi commented Oct 8, 2016

Cool - keepFnArgs and keepFnName.

Hit a bug - function foo(a,b) { b } -> function foo(b) { b } which is totally wrong.

@boopathi
Copy link
Member Author

boopathi commented Oct 8, 2016

Updated.

@kangax
Copy link
Member

kangax commented Oct 9, 2016

Great. Could you update benchmarks table as well.

@boopathi
Copy link
Member Author

boopathi commented Oct 9, 2016

The diff is

-uglify     21.79kB 221%    7.29kB 169%     1ms        247ms
-closure    21.67kB 223%    7.37kB 167%     2ms        1223ms
-babili     21.9kB  219%    7.46kB 164%     2ms        722ms
-closure js 24.01kB 191%    8.04kB 144%     2ms        3301ms
+uglify     21.79kB 221%    7.29kB 169%     2ms        387ms
+closure    21.67kB 223%    7.37kB 167%     2ms        3195ms
+babili     21.86kB 220%    7.46kB 163%     2ms        943ms
+closure js 24.01kB 191%    8.04kB 144%     2ms        4943ms

we need to move running benchmarks on same machine / with same hardware config. maybe on CI?

// this is used for tracking fn params that can be removed
// as traversal takes place from left and
// unused params can be removed only on the right
const markForRemoval = Symbol("markForRemoval");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: shouldn't it be markedForRemoval?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmmm. IMO, depends on context,

at the place of assignment, mark this for removal,
at the place of verifying, is this marked for removal,

Not sure. IMO, either way should be fine.

break;
}

Object.defineProperty(binding, markForRemoval, {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to defineProperty here instead of just assigning it? Is this because we don't want to taint binding with "irrelevant" enumerable prop? I'm just worried about performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohhh . defineProp has perf drawbacks!! didn't know. I just didn't want it to be enumerable.

@kangax kangax merged commit 10b114f into master Oct 13, 2016
@kangax kangax deleted the keep-f-args branch October 13, 2016 01:08
@hzoo
Copy link
Member

hzoo commented Oct 13, 2016

We should update the readme when possible when changing options + explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

babel-plugin-minify-dead-code-elimination should remove unused arguments
3 participants