Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions Other/Citra_mods/Citra_3DS_Manager.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Comment on lines +70 to +74
val := remaining[keyCandidate]
line := keyCandidate "=" val
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To maintain consistency with the optimization goal of avoiding temporary string allocations in AutoHotkey v1, this chained assignment should be split into separate operations. While this line executes at most once per update, it currently creates a temporary string for the expression keyCandidate "=" val before assignment, which contradicts the rationale provided in the PR description for other similar changes in the parsing and finalization loops.

          line := keyCandidate
          line .= "="
          line .= 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)
Expand Down
Loading