Skip to content

Commit

Permalink
lib: improve for-loop in master.js
Browse files Browse the repository at this point in the history
  • Loading branch information
gengjiawen committed Mar 1, 2019
1 parent 8a273f1 commit 879e60a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/internal/cluster/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ cluster.setupMaster = function(options) {
if (message.cmd !== 'NODE_DEBUG_ENABLED')
return;

var key;
for (key in cluster.workers) {
const worker = cluster.workers[key];

for (const worker of Object.values(cluster.workers)) {
if (worker.state === 'online' || worker.state === 'listening') {
process._debugProcess(worker.process.pid);
} else {
Expand Down Expand Up @@ -227,11 +224,10 @@ cluster.disconnect = function(cb) {
if (workers.length === 0) {
process.nextTick(() => intercom.emit('disconnect'));
} else {
for (var key in workers) {
key = workers[key];

if (cluster.workers[key].isConnected())
cluster.workers[key].disconnect();
for (const worker of Object.values(cluster.workers)) {
if (worker.isConnected()) {
worker.disconnect();
}
}
}

Expand Down

0 comments on commit 879e60a

Please sign in to comment.