From ca47cddc4c568fdd33dc018cb21f51db2da3f575 Mon Sep 17 00:00:00 2001 From: Ven0m0 <82972344+Ven0m0@users.noreply.github.com> Date: Sun, 3 May 2026 14:29:57 +0000 Subject: [PATCH] Optimize string concatenation and looping in Citra 3DS Manager Implements an early-exit pattern and split string assignments in the UpdateConfig loop to minimize lookup overhead and prevent the creation of intermediate temporary strings in AutoHotkey v1. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- Other/Citra_mods/Citra_3DS_Manager.ahk | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Other/Citra_mods/Citra_3DS_Manager.ahk b/Other/Citra_mods/Citra_3DS_Manager.ahk index ec79d4a..a7f4ebd 100644 --- a/Other/Citra_mods/Citra_3DS_Manager.ahk +++ b/Other/Citra_mods/Citra_3DS_Manager.ahk @@ -62,23 +62,32 @@ UpdateConfig(content, updates){ VarSetCapacity(newContent, (StrLen(content) + updates.Count() * 100 + 1) * (A_IsUnicode ? 2 : 1)) newContent := "" + remCount := remaining.Count() + Loop, Parse, content, `n, `r { line := A_LoopField - pos := InStr(line, "=") - if (pos > 1){ - keyCandidate := RTrim(SubStr(line, 1, pos-1)) - if (remaining.HasKey(keyCandidate)){ - val := remaining[keyCandidate] - line := keyCandidate "=" val - remaining.Delete(keyCandidate) + if (remCount > 0) { + pos := InStr(line, "=") + if (pos > 1){ + keyCandidate := RTrim(SubStr(line, 1, pos-1)) + if (remaining.HasKey(keyCandidate)){ + val := remaining[keyCandidate] + line := keyCandidate "=" val + remaining.Delete(keyCandidate) + remCount-- + } } } - newContent .= line "`n" + newContent .= line + newContent .= "`n" } for k, v in remaining { - newContent .= k "=" v "`n" + newContent .= k + newContent .= "=" + newContent .= v + newContent .= "`n" } return SubStr(newContent, 1, -1)