From afbc1e280c219008e0afeddc6bf4ae2d00a85b2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 13 Feb 2021 11:40:47 +0100 Subject: [PATCH] Simplify worker choosing (#138) --- src/pools/abstract-pool.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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 -- 2.34.1