Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit edd7c57

Browse files
mcollinaBridgeAR
authored andcommittedSep 24, 2019
events: improve performance of EventEmitter.emit
This restore some performance we lost when we introduced primordialias. Improvements are up to +100%. PR-URL: #29633 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 170862e commit edd7c57

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎lib/events.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'use strict';
2323

2424
const { Math, Object, Reflect } = primordials;
25+
const apply = Reflect.apply;
2526

2627
var spliceOne;
2728

@@ -206,12 +207,12 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
206207
return false;
207208

208209
if (typeof handler === 'function') {
209-
Reflect.apply(handler, this, args);
210+
apply(handler, this, args);
210211
} else {
211212
const len = handler.length;
212213
const listeners = arrayClone(handler, len);
213214
for (var i = 0; i < len; ++i)
214-
Reflect.apply(listeners[i], this, args);
215+
apply(listeners[i], this, args);
215216
}
216217

217218
return true;

0 commit comments

Comments
 (0)
Please sign in to comment.