Skip to content

Commit c2fcb5f

Browse files
cjihriglpinca
authored andcommitted
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: nodejs#12043 PR-URL: nodejs#12501 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 41de99d commit c2fcb5f

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
@@ -349,22 +349,13 @@ EventEmitter.prototype.removeListener =
349349
if (position < 0)
350350
return this;
351351

352-
if (list.length === 1) {
353-
if (--this._eventsCount === 0) {
354-
this._events = new EventHandlers();
355-
return this;
356-
} else {
357-
delete events[type];
358-
}
359-
} else if (position === 0) {
352+
if (position === 0)
360353
list.shift();
361-
if (list.length === 1)
362-
events[type] = list[0];
363-
} else {
354+
else
364355
spliceOne(list, position);
365-
if (list.length === 1)
366-
events[type] = list[0];
367-
}
356+
357+
if (list.length === 1)
358+
events[type] = list[0];
368359

369360
if (events.removeListener)
370361
this.emit('removeListener', type, originalListener || listener);

0 commit comments

Comments
 (0)