Skip to content
Closed
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
Optimize event handling with large arguments
In V8, it is faster to create an array by ```[]``` instead of ``` new Array()'''.
  • Loading branch information
simonkcleung authored Nov 16, 2016
commit ccf0b0c7885e237b19adba914fb50f9daa4e404d
4 changes: 2 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down