Skip to content

Commit 58066d1

Browse files
committed
events: remove unreachable code
Commit 8d386ed stopped the Event Emitter implementation from storing arrays containing a single listener. This change left a section of code in removeListener() as unreachable. This commit removes the unreachable code. Refs: #12043 PR-URL: #12501 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 1159a71 commit 58066d1

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

lib/events.js

+5-14
Original file line numberDiff line numberDiff line change
@@ -374,22 +374,13 @@ EventEmitter.prototype.removeListener =
374374
if (position < 0)
375375
return this;
376376

377-
if (list.length === 1) {
378-
if (--this._eventsCount === 0) {
379-
this._events = Object.create(null);
380-
return this;
381-
} else {
382-
delete events[type];
383-
}
384-
} else if (position === 0) {
377+
if (position === 0)
385378
list.shift();
386-
if (list.length === 1)
387-
events[type] = list[0];
388-
} else {
379+
else
389380
spliceOne(list, position);
390-
if (list.length === 1)
391-
events[type] = list[0];
392-
}
381+
382+
if (list.length === 1)
383+
events[type] = list[0];
393384

394385
if (events.removeListener)
395386
this.emit('removeListener', type, originalListener || listener);

0 commit comments

Comments
 (0)