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

Fix arguments leakage in fn.bind polyfill #853

Merged
merged 1 commit into from
Aug 5, 2014
Merged

Conversation

Fishrock123
Copy link
Contributor

Bluebird has done a bunch of research into Javascript optimization blockers, which includes strict arguments usage:

https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments

@englercj
Copy link
Member

Pretty sure this is going to pass along the thisArg that was passed in since you are not slicing off the first param of arguments. Would you mind making some tests for this function and trying it out?

@Fishrock123
Copy link
Contributor Author

Whoops I didn't notice the top one sliced an arg off, I'll get it patched up tonight!

Edit: yeah I'll also cook up some tests.

@Fishrock123
Copy link
Contributor Author

@englercj Maybe a better question is, do we need this?

I'm not sure that any browser that has a decently running canvas wouldn't have fn.bind

In any case I'm actually not sure how to test this, since our test env will not use our polyfill but rather the native version.

@englercj
Copy link
Member

To test it, export it as another function PIXI.utils.bind or something. Then test against that.

Do we need it? That is a great question, I would be surprised if we did...

@Fishrock123
Copy link
Contributor Author

@englercj this is the fixed version. I'd rather just test the logic separately but it is up to you guys.

Here's the compatibility tables for fn.bind

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Browser_compatibility
http://kangax.github.io/compat-table/es5/#Function.prototype.bind

Seems to be missing from Safari 5 / 5.1

@englercj
Copy link
Member

That stinks! Canvas was added to safari in 2.0, so we do need this polyfill I guess...

I will merge this in if you write a few simple tests for it :D THANKS!

@Fishrock123
Copy link
Contributor Author

Preliminary tests / benchmarks against an existing fn.bind polyfill on jsperf: http://jsperf.com/bind-vs-custom/5

@englercj
Copy link
Member

Very cool! Seems like there is a perf increase for sure using this method instead of what we have now!

(btw what I meant by tests were just a couple unit tests in the PR itself 😄)

@Fishrock123
Copy link
Contributor Author

Yeah I know, I'll write them tomorrow haha

englercj added a commit that referenced this pull request Aug 5, 2014
Fix arguments leakage in fn.bind polyfill
@englercj englercj merged commit d744c30 into pixijs:dev Aug 5, 2014
@Fishrock123
Copy link
Contributor Author

@englercj did you do any testing? Sorry I've been away and busy. :s

@englercj
Copy link
Member

englercj commented Aug 5, 2014

Nah, just going through and cleaning some PRs decided to merge this for now. Feel free to add tests though still :D

@lock
Copy link

lock bot commented Feb 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants