From: Jérôme Benoit Date: Sat, 19 Aug 2023 22:16:20 +0000 (+0200) Subject: refactor: remove unneeded branching in WCS code X-Git-Tag: v2.6.31~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fce028d66b18a0e46571eb82457055fe3177d702;p=poolifier.git refactor: remove unneeded branching in WCS code Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index d0171221..c2b4d1d3 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -195,20 +195,10 @@ export abstract class AbstractWorkerChoiceStrategy< } /** - * Assign to nextWorkerNodeKey property the chosen worker node key. + * Check the next worker node eligibility. * * @param chosenWorkerNodeKey - The chosen worker node key. */ - protected assignChosenWorkerNodeKey ( - chosenWorkerNodeKey: number | undefined - ): void { - if (chosenWorkerNodeKey != null) { - this.nextWorkerNodeKey = chosenWorkerNodeKey - } else { - this.nextWorkerNodeKey = undefined - } - } - protected checkNextWorkerNodeEligibility ( chosenWorkerNodeKey: number | undefined ): void { 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 bc8f8b48..094e9b02 100644 --- a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts @@ -70,8 +70,7 @@ export class FairShareWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number | undefined { - const chosenWorkerNodeKey = this.fairShareNextWorkerNodeKey() - this.assignChosenWorkerNodeKey(chosenWorkerNodeKey) + this.nextWorkerNodeKey = this.fairShareNextWorkerNodeKey() return this.nextWorkerNodeKey } 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 224ca540..6fad8939 100644 --- a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts @@ -61,8 +61,7 @@ export class LeastBusyWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number | undefined { - const chosenWorkerNodeKey = this.leastBusyNextWorkerNodeKey() - this.assignChosenWorkerNodeKey(chosenWorkerNodeKey) + this.nextWorkerNodeKey = this.leastBusyNextWorkerNodeKey() return this.nextWorkerNodeKey } 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 0f992cfa..00919f33 100644 --- a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts @@ -57,8 +57,7 @@ export class LeastEluWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number | undefined { - const chosenWorkerNodeKey = this.leastEluNextWorkerNodeKey() - this.assignChosenWorkerNodeKey(chosenWorkerNodeKey) + this.nextWorkerNodeKey = this.leastEluNextWorkerNodeKey() return this.nextWorkerNodeKey } 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 515b4e93..4387d792 100644 --- a/src/pools/selection-strategies/least-used-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-used-worker-choice-strategy.ts @@ -42,8 +42,7 @@ export class LeastUsedWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number | undefined { - const chosenWorkerNodeKey = this.leastUsedNextWorkerNodeKey() - this.assignChosenWorkerNodeKey(chosenWorkerNodeKey) + this.nextWorkerNodeKey = this.leastUsedNextWorkerNodeKey() return this.nextWorkerNodeKey }