From ccf0b0c7885e237b19adba914fb50f9daa4e404d Mon Sep 17 00:00:00 2001 From: simonkcleung Date: Wed, 16 Nov 2016 23:42:49 +0800 Subject: [PATCH] Optimize event handling with large arguments In V8, it is faster to create an array by ```[]``` instead of ``` new Array()'''. --- lib/events.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/events.js b/lib/events.js index e7202bfedd0c55..e745c087fdfb48 100644 --- a/lib/events.js +++ b/lib/events.js @@ -195,9 +195,9 @@ EventEmitter.prototype.emit = function emit(type) { break; // slower default: - args = new Array(len - 1); + args = []; for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; + args.push(arguments[i]); emitMany(handler, isFn, this, args); }