From 2249337a02553b460d4e624ad2139fa343a3fa18 Mon Sep 17 00:00:00 2001 From: Cj Date: Wed, 6 Mar 2024 19:50:45 +0000 Subject: [PATCH] Small optimization (!248) Change `foreach` to use `for of` instead, `for of` is faster than `foreach` Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/248 Co-authored-by: Cj Co-committed-by: Cj --- project/src/controllers/QuestController.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/src/controllers/QuestController.ts b/project/src/controllers/QuestController.ts index 73fd42fb..c4d72fd4 100644 --- a/project/src/controllers/QuestController.ts +++ b/project/src/controllers/QuestController.ts @@ -887,10 +887,11 @@ export class QuestController childItems.shift(); // Remove the parent // Sort by the current `location` and update - childItems.sort((a, b) => a.location > b.location ? 1 : -1).forEach((item, index) => + childItems.sort((a, b) => a.location > b.location ? 1 : -1); + for (const [index, item] of childItems.entries()) { item.location = index; - }); + } } } }