Optimize a loop in the worker related code.
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 21 Aug 2021 20:02:28 +0000 (22:02 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 21 Aug 2021 20:02:28 +0000 (22:02 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/worker/WorkerSet.ts

index e224870d56b4b44757ba6185e6a1ff96407b15f7..e6421b14ab746fd816eadac1566fa44c4e705dbf 100644 (file)
@@ -98,11 +98,12 @@ export default class WorkerSet<T> 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;
   }
 }