Skip to content

Commit 984e46f

Browse files
slagiewkanodejs-github-bot
authored andcommitted
events: inline iterationCondition hybrid dispatch closure
While more readable, the removed closure overhead unlocks 10-20% in eventtarget.js benchmark. Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com> PR-URL: #64473 Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 59dd75b commit 984e46f

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

lib/internal/event_target.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,8 @@ class EventTarget {
809809
let handler = root.next;
810810
let next;
811811

812-
const iterationCondition = () => {
813-
if (handler === undefined) {
814-
return false;
815-
}
816-
return root.resistStopPropagation || handler.passive || event?.[kStop] !== true;
817-
};
818-
while (iterationCondition()) {
812+
while (handler !== undefined &&
813+
(root.resistStopPropagation || handler.passive || event?.[kStop] !== true)) {
819814
// Cache the next item in case this iteration removes the current one
820815
next = handler.next;
821816

0 commit comments

Comments
 (0)