From: Jérôme Benoit Date: Wed, 15 May 2024 13:44:55 +0000 (+0200) Subject: perf: remove unneeded branching in worker choice strategies X-Git-Tag: v4.0.8~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7f13b544e1f3041a2a2e8cf16ec714b4d2e7c2ce;p=poolifier.git perf: remove unneeded branching in worker choice strategies Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts index 2f2686e9..357b770a 100644 --- a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts @@ -81,9 +81,6 @@ export class FairShareWorkerChoiceStrategy< } private fairShareNextWorkerNodeKey (): number | undefined { - if (this.pool.workerNodes.length === 0) { - return undefined - } return this.pool.workerNodes.reduce( (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => { if (workerNode.strategyData?.virtualTaskEndTimestamp == null) { diff --git a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts index a9fe3d1c..b07a9d1c 100644 --- a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts @@ -69,9 +69,6 @@ export class LeastBusyWorkerChoiceStrategy< } private leastBusyNextWorkerNodeKey (): number | undefined { - if (this.pool.workerNodes.length === 0) { - return undefined - } return this.pool.workerNodes.reduce( (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => { return this.isWorkerNodeReady(workerNodeKey) && diff --git a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts index 9cb28bac..6eaaacfb 100644 --- a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts @@ -65,9 +65,6 @@ export class LeastEluWorkerChoiceStrategy< } private leastEluNextWorkerNodeKey (): number | undefined { - if (this.pool.workerNodes.length === 0) { - return undefined - } return this.pool.workerNodes.reduce( (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => { return this.isWorkerNodeReady(workerNodeKey) && diff --git a/src/pools/selection-strategies/least-used-worker-choice-strategy.ts b/src/pools/selection-strategies/least-used-worker-choice-strategy.ts index cd93d752..601b72be 100644 --- a/src/pools/selection-strategies/least-used-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-used-worker-choice-strategy.ts @@ -51,9 +51,6 @@ export class LeastUsedWorkerChoiceStrategy< } private leastUsedNextWorkerNodeKey (): number | undefined { - if (this.pool.workerNodes.length === 0) { - return undefined - } return this.pool.workerNodes.reduce( (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => { return this.isWorkerNodeReady(workerNodeKey) &&