summaryrefslogtreecommitdiff
path: root/lib/events.js
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2017-01-02 03:17:21 -0500
committerBrian White <mscdex@mscdex.net>2017-01-05 02:53:18 -0500
commitaab1dd6ff4a30191f36d6a7ed3fd7e47477dd2fb (patch)
treed9d12ab8d5e07ff1099323f27f77bed90f9cd46b /lib/events.js
parent7889416b8a93b70fbc1ebfe65b8918f84216c347 (diff)
downloadnode-new-aab1dd6ff4a30191f36d6a7ed3fd7e47477dd2fb.tar.gz
events: improve removeListener() performance
array.shift() seems to be faster than arrayClone() when the item to remove is at the front (at least with V8 5.4). PR-URL: https://github.com/nodejs/node/pull/10572 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'lib/events.js')
-rw-r--r--lib/events.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/events.js b/lib/events.js
index 6a8345ab7b..209700e65a 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -360,6 +360,8 @@ EventEmitter.prototype.removeListener =
} else {
delete events[type];
}
+ } else if (position === 0) {
+ list.shift();
} else {
spliceOne(list, position);
}