From d29511f991ab82e2e0fffcdb6453218a82545dab Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Tue, 22 Sep 2015 17:17:11 -0500 Subject: [PATCH] Prevent v8 deopt when using [].slice.call(arguments) --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1c78176..0be4a43 100644 --- a/index.js +++ b/index.js @@ -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) {