Skip to content

Commit

Permalink
Prevent v8 deopt when using [].slice.call(arguments)
Browse files Browse the repository at this point in the history
  • Loading branch information
STRML committed Sep 22, 2015
1 parent 4d18307 commit d29511f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,14 @@ Emitter.prototype.removeEventListener = function(event, fn){

Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)

var args = new Array(arguments.length - 1)
, callbacks = this._callbacks['$' + event];

for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}

if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
Expand Down

0 comments on commit d29511f

Please sign in to comment.