mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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>
This commit is contained in:
1 parent
2f4577c07d
commit
ded17579e5
1 file changed
+2
@@ -360,6 +360,8 @@ EventEmitter.prototype.removeListener =
|
||||
} else {
|
||||
delete events[type];
|
||||
}
|
||||
} else if (position === 0) {
|
||||
list.shift();
|
||||
} else {
|
||||
spliceOne(list, position);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user