diff options
author | Brian White <mscdex@mscdex.net> | 2017-01-02 03:17:21 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-01-05 02:53:18 -0500 |
commit | aab1dd6ff4a30191f36d6a7ed3fd7e47477dd2fb (patch) | |
tree | d9d12ab8d5e07ff1099323f27f77bed90f9cd46b /lib/events.js | |
parent | 7889416b8a93b70fbc1ebfe65b8918f84216c347 (diff) | |
download | node-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.js | 2 |
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); } |