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

Update Signal.js #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,18 @@
if (! this.active) {
return;
}

/**
* When copying the arguments variable using Array.prototype.slice.call V8 disables optimization for the calling method.
* We avoid this issue here by coping arguments to a pre-allocated array.
* see https://code.google.com/p/v8/issues/detail?id=3037
*/
var len = arguments.length, paramsArr = new Array(len);
Copy link
Owner

Choose a reason for hiding this comment

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

can you add a comment explaining why we are not using Array#slice.call for future reference? (just so in +6mo we still know why it was implemented like this)

for (var i=0; i < len; ++i) {
paramsArr[i] = arguments[i];
}

var paramsArr = Array.prototype.slice.call(arguments),
n = this._bindings.length,
var n = this._bindings.length,
bindings;

if (this.memorize) {
Expand Down