From: Jérôme Benoit Date: Wed, 18 Oct 2023 15:32:55 +0000 (+0200) Subject: perf: remove unneeded nullish check X-Git-Tag: v3.0.3~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8e5a7cf9360dd0cfd5af8b21c245c10b6983cca4;p=poolifier.git perf: remove unneeded nullish check Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 645a31e1..ef5ebead 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -495,10 +495,7 @@ export abstract class AbstractPool< private checkMessageWorkerId (message: MessageValue): void { if (message.workerId == null) { throw new Error('Worker message received without worker id') - } else if ( - message.workerId != null && - this.getWorkerNodeKeyByWorkerId(message.workerId) === -1 - ) { + } else if (this.getWorkerNodeKeyByWorkerId(message.workerId) === -1) { throw new Error( `Worker message received from unknown worker '${message.workerId}'` ) diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index e10521fc..43135467 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -405,7 +405,7 @@ export abstract class AbstractWorker< private checkMessageWorkerId (message: MessageValue): void { if (message.workerId == null) { throw new Error('Message worker id is not set') - } else if (message.workerId != null && message.workerId !== this.id) { + } else if (message.workerId !== this.id) { throw new Error( `Message worker id ${message.workerId} does not match the worker id ${this.id}` )