From: Jérôme Benoit Date: Sat, 13 Feb 2021 10:40:47 +0000 (+0100) Subject: Simplify worker choosing (#138) X-Git-Tag: v2.0.0-beta.2~39 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=afbc1e280c219008e0afeddc6bf4ae2d00a85b2e;p=poolifier.git Simplify worker choosing (#138) --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 1ae188dd..1ccaca8b 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -150,13 +150,9 @@ export abstract class AbstractPool< } protected chooseWorker (): Worker { - if (this.workers.length - 1 === this.nextWorker) { - this.nextWorker = 0 - return this.workers[this.nextWorker] - } else { - this.nextWorker++ - return this.workers[this.nextWorker] - } + this.nextWorker = + this.nextWorker === this.workers.length - 1 ? 0 : this.nextWorker + 1 + return this.workers[this.nextWorker] } protected abstract newWorker (): Worker