From: Jérôme Benoit Date: Sat, 21 Aug 2021 20:02:28 +0000 (+0200) Subject: Optimize a loop in the worker related code. X-Git-Tag: v1.0.40~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0e7a11e1621315c9b1ae42b8bb5a8078336073a1;p=e-mobility-charging-stations-simulator.git Optimize a loop in the worker related code. Signed-off-by: Jérôme Benoit --- diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index e224870d..e6421b14 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -98,11 +98,12 @@ export default class WorkerSet extends WorkerAbstract { private getWorkerSetElementByWorker(worker: Worker): WorkerSetElement { let workerSetElt: WorkerSetElement; - this.workerSet.forEach((workerSetElement) => { + for (const workerSetElement of this.workerSet) { if (workerSetElement.worker.threadId === worker.threadId) { workerSetElt = workerSetElement; + break; } - }); + } return workerSetElt; } }