refactor: define a variable only when needed
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 15 Aug 2024 12:39:44 +0000 (14:39 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 15 Aug 2024 12:39:44 +0000 (14:39 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts

index a1b6b02e062da9ef12fa1c24dd3a05ef96ebed39..7aae2c89c7cdaa67e7b162159901fa0cccf3a99a 100644 (file)
@@ -1961,7 +1961,6 @@ export abstract class AbstractPool<
         `Worker node with key '${workerNodeKey.toString()}' not found in pool`
       )
     }
-    const workerNodeTasksUsage = this.workerNodes[workerNodeKey].usage.tasks
     if (
       !workerNodeInfo.continuousStealing &&
       (this.cannotStealTask() ||
@@ -1974,6 +1973,7 @@ export abstract class AbstractPool<
     ) {
       return
     }
+    const workerNodeTasksUsage = this.workerNodes[workerNodeKey].usage.tasks
     if (
       workerNodeInfo.continuousStealing &&
       (workerNodeTasksUsage.executing > 0 ||