Skip to content

Commit ded1757

Browse files
mscdexitaloacasas
authored andcommitted
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: #10572 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 2f4577c commit ded1757

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/events.js

+2
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ EventEmitter.prototype.removeListener =
360360
} else {
361361
delete events[type];
362362
}
363+
} else if (position === 0) {
364+
list.shift();
363365
} else {
364366
spliceOne(list, position);
365367
}

0 commit comments

Comments
 (0)