mirror of https://github.com/nodejs/node.git
events: loop backwards in removeListener
`removeAllListeners` is removing events from end to start. Therefore it spends O(n^2) time, since `removeListener` is searching from start to end.pull/24507/merge
parent
d09ab61dcd
commit
3e64b5677f
|
@ -201,7 +201,7 @@ EventEmitter.prototype.removeListener = function(type, listener) {
|
|||
this.emit('removeListener', type, listener);
|
||||
|
||||
} else if (typeof list === 'object') {
|
||||
for (i = 0; i < length; i++) {
|
||||
for (i = length; i-- > 0;) {
|
||||
if (list[i] === listener ||
|
||||
(list[i].listener && list[i].listener === listener)) {
|
||||
position = i;
|
||||
|
|
Loading…
Reference in New Issue