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

Prevent arguments leak #150

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Landmaster
Copy link

In the original code, the arguments object is leaked, which disables optimization in the V8 engine. This pull request rectifies this by manually copying the passed-in arguments to a new array, keeping arguments intact.

@nazar-pc
Copy link
Contributor

nazar-pc commented Aug 6, 2017

I don't think extra code really worth it. What kind of performance hit are we even talking about? Can you measure when does it make a difference?

Also if we drop support for even more old browsers, we can just write something like this:

sprintf(key, ...argv) {

@Llorx
Copy link

Llorx commented Dec 3, 2018

Well, depends a lot in the amount of consecutive calls to sprintf that you do. I'm maintaining a program that handles tens of thousands of inputs and this is a neat performance hit.

I think that avoiding V8 deoptimizations is a good practice. Actually preventing V8 from optimizing functions is a really bad practice, as you don't actually know what V8 do in the back-end and if in the future they are going to add new ways of optimizations that this code will prevent.

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.

3 participants