Browse Source

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>
v6
Brian White 8 years ago
parent
commit
aab1dd6ff4
No known key found for this signature in database GPG Key ID: 606D7358F94DA209
  1. 2
      lib/events.js

2
lib/events.js

@ -360,6 +360,8 @@ EventEmitter.prototype.removeListener =
} else {
delete events[type];
}
} else if (position === 0) {
list.shift();
} else {
spliceOne(list, position);
}

Loading…
Cancel
Save