From 867d34f8cfc5f4a8fbaa4eb27520c8b9469cc80e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 3 Apr 2023 12:04:06 +0200 Subject: [PATCH] perf: remove unneeded nullish check in hot code paths MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../round-robin-worker-choice-strategy.ts | 2 +- .../weighted-round-robin-worker-choice-strategy.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts index a2327587..9bf49a3c 100644 --- a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts @@ -26,7 +26,7 @@ export class RoundRobinWorkerChoiceStrategy< /** {@inheritDoc} */ public choose (): Worker { - const chosenWorker = this.pool.workers[this.nextWorkerId]?.worker + const chosenWorker = this.pool.workers[this.nextWorkerId].worker this.nextWorkerId = this.nextWorkerId === this.pool.workers.length - 1 ? 0 diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index 9ee4fa65..5c5e6474 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -67,7 +67,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< /** {@inheritDoc} */ public choose (): Worker { - const chosenWorker = this.pool.workers[this.currentWorkerId]?.worker + const chosenWorker = this.pool.workers[this.currentWorkerId].worker if (this.isDynamicPool && !this.workersTaskRunTime.has(chosenWorker)) { this.initWorkerTaskRunTime(chosenWorker) } @@ -89,7 +89,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< ? 0 : this.currentWorkerId + 1 this.setWorkerTaskRunTime( - this.pool.workers[this.currentWorkerId]?.worker, + this.pool.workers[this.currentWorkerId].worker, workerTaskWeight, 0 ) -- 2.34.1