cluster: replace forEach with for-of loop

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
PR-URL: https://github.com/nodejs/node/pull/50317
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Jérôme Benoit 2024-05-12 19:58:40 +02:00 committed by GitHub
parent c8805b8043
commit 7b2dc79437
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -270,14 +270,14 @@ function _disconnect(primaryInitiated) {
} }
} }
handles.forEach((handle) => { for (const handle of handles.values()) {
waitingCount++; waitingCount++;
if (handle[owner_symbol]) if (handle[owner_symbol])
handle[owner_symbol].close(checkWaitingCount); handle[owner_symbol].close(checkWaitingCount);
else else
handle.close(checkWaitingCount); handle.close(checkWaitingCount);
}); }
handles.clear(); handles.clear();
checkWaitingCount(); checkWaitingCount();

View File

@ -152,10 +152,10 @@ function removeWorker(worker) {
function removeHandlesForWorker(worker) { function removeHandlesForWorker(worker) {
assert(worker); assert(worker);
handles.forEach((handle, key) => { for (const { 0: key, 1: handle } of handles) {
if (handle.remove(worker)) if (handle.remove(worker))
handles.delete(key); handles.delete(key);
}); }
} }
cluster.fork = function(env) { cluster.fork = function(env) {