summaryrefslogtreecommitdiff
path: root/lib/events.js
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2019-09-20 19:06:20 +0200
committerMatteo Collina <hello@matteocollina.com>2019-09-24 09:12:59 +0200
commitc5f5f84a33967862036c7d87f4bbde6a59d3820a (patch)
tree5f01e99756ad08c470e9bd56c895c34a7d63e583 /lib/events.js
parent1fa403762c035dca35bae9a18a4e4c3edf9d55f3 (diff)
downloadandroid-node-v8-c5f5f84a33967862036c7d87f4bbde6a59d3820a.tar.gz
android-node-v8-c5f5f84a33967862036c7d87f4bbde6a59d3820a.tar.bz2
android-node-v8-c5f5f84a33967862036c7d87f4bbde6a59d3820a.zip
events: improve performance of EventEmitter.emit
This restore some performance we lost when we introduced primordialias. Improvements are up to +100%. PR-URL: https://github.com/nodejs/node/pull/29633 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/events.js')
-rw-r--r--lib/events.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/events.js b/lib/events.js
index f6e4996d20..1356806f65 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -22,6 +22,7 @@
'use strict';
const { Math, Object, Reflect } = primordials;
+const apply = Reflect.apply;
var spliceOne;
@@ -206,12 +207,12 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
return false;
if (typeof handler === 'function') {
- Reflect.apply(handler, this, args);
+ apply(handler, this, args);
} else {
const len = handler.length;
const listeners = arrayClone(handler, len);
for (var i = 0; i < len; ++i)
- Reflect.apply(listeners[i], this, args);
+ apply(listeners[i], this, args);
}
return true;