From da33046880c908cb36b540cdaf9d62aabb7014a7 Mon Sep 17 00:00:00 2001 From: Ven0m0 <82972344+Ven0m0@users.noreply.github.com> Date: Tue, 10 Feb 2026 06:56:09 +0000 Subject: [PATCH 1/4] perf: Optimize directory emptiness check in Citra Mod Manager - Modifies `Loop, Files` to `Break` immediately after finding the first item, changing complexity from O(N) to O(1). - Updates dependent UI message to be generic ("Dir is not empty") instead of specific count ("Dir has X items"), as the count is no longer calculated. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- Other/Citra_mods/Citra_Mod_Manager.ahk | 5 ++- optimize_script.py | 45 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 optimize_script.py diff --git a/Other/Citra_mods/Citra_Mod_Manager.ahk b/Other/Citra_mods/Citra_Mod_Manager.ahk index c917d2a..e997231 100644 --- a/Other/Citra_mods/Citra_Mod_Manager.ahk +++ b/Other/Citra_mods/Citra_Mod_Manager.ahk @@ -62,14 +62,17 @@ FileActions(Root, Button) Quellpfad := button.Path vCount :=0 Loop, Files, %Checkdir%\*, DF ;Loop through items in dir + { vCount++ ;Increment vCount for each item + Break ;Optimization: Break after finding the first item + } If !vCount ;Is vCount empty? { FileCopyDir, %Quellpfad%, %Fullpath% MsgBox % "Copied " button.Name } Else ;Otherwise vCount is NOT empty... - MsgBox % "Dir has " vCount " item(s). Can't copy" + MsgBox % "Dir is not empty. Can't copy" } GuiClose: diff --git a/optimize_script.py b/optimize_script.py new file mode 100644 index 0000000..3d964ce --- /dev/null +++ b/optimize_script.py @@ -0,0 +1,45 @@ +import sys + +file_path = "Other/Citra_mods/Citra_Mod_Manager.ahk" + +with open(file_path, "r") as f: + lines = f.readlines() + +new_lines = [] +skip_next = False +for i in range(len(lines)): + if skip_next: + skip_next = False + continue + + line = lines[i] + + # Check for the specific Loop line + if "Loop, Files, %Checkdir%\*, DF" in line: + # We found the loop line. We keep it, then insert the block. + new_lines.append(line) + # We need to construct the block. + # Original indentation of the Loop line is 8 spaces. + # So brace should be 8 spaces? Or standard is open brace on same line or next line at same indent? + # AHK style varies. Let's use: + # Loop... + # { + # vCount++ + # Break + # } + new_lines.append(" {\n") + new_lines.append(" vCount++ ;Increment vCount for each item\n") + new_lines.append(" Break ;Optimization: Break after finding the first item\n") + new_lines.append(" }\n") + + # The original code had the single statement on the next line. + # We need to skip it if it is indeed the vCount++ line. + if i + 1 < len(lines) and "vCount++" in lines[i+1]: + skip_next = True + elif 'MsgBox % "Dir has " vCount " item(s). Can\'t copy"' in line: + new_lines.append(' MsgBox % "Dir is not empty. Can\'t copy"\n') + else: + new_lines.append(line) + +with open(file_path, "w") as f: + f.writelines(new_lines) From eb28ce5165b8dbe687bea2ad44a7ecafdd11f5e1 Mon Sep 17 00:00:00 2001 From: Ven0m0 Date: Tue, 10 Feb 2026 11:19:52 +0100 Subject: [PATCH 2/4] Update Other/Citra_mods/Citra_Mod_Manager.ahk Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Other/Citra_mods/Citra_Mod_Manager.ahk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Other/Citra_mods/Citra_Mod_Manager.ahk b/Other/Citra_mods/Citra_Mod_Manager.ahk index e997231..97a2494 100644 --- a/Other/Citra_mods/Citra_Mod_Manager.ahk +++ b/Other/Citra_mods/Citra_Mod_Manager.ahk @@ -61,12 +61,12 @@ FileActions(Root, Button) Checkdir := Zielpfad "\" button.Ziel Quellpfad := button.Path vCount :=0 - Loop, Files, %Checkdir%\*, DF ;Loop through items in dir + Loop, Files, %Checkdir%\*, DF ;Loop through items in dir, stopping after the first one found { - vCount++ ;Increment vCount for each item + vCount++ ;Set vCount > 0 once to indicate that the directory has at least one item Break ;Optimization: Break after finding the first item } - If !vCount ;Is vCount empty? + If !vCount ;Is vCount still zero (directory empty)? { FileCopyDir, %Quellpfad%, %Fullpath% MsgBox % "Copied " button.Name From f8e8edfb55a9203539da77717009916ecb50229d Mon Sep 17 00:00:00 2001 From: Ven0m0 Date: Tue, 10 Feb 2026 11:20:17 +0100 Subject: [PATCH 3/4] Update Other/Citra_mods/Citra_Mod_Manager.ahk Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Other/Citra_mods/Citra_Mod_Manager.ahk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Other/Citra_mods/Citra_Mod_Manager.ahk b/Other/Citra_mods/Citra_Mod_Manager.ahk index 97a2494..47c7e8c 100644 --- a/Other/Citra_mods/Citra_Mod_Manager.ahk +++ b/Other/Citra_mods/Citra_Mod_Manager.ahk @@ -60,18 +60,18 @@ FileActions(Root, Button) Fullpath := Zielpfad "\" button.Ziel "\" button.Name Checkdir := Zielpfad "\" button.Ziel Quellpfad := button.Path - vCount :=0 - Loop, Files, %Checkdir%\*, DF ;Loop through items in dir, stopping after the first one found + dirHasItems := false + Loop, Files, %Checkdir%\*, DF ;Loop through items in dir { - vCount++ ;Set vCount > 0 once to indicate that the directory has at least one item + dirHasItems := true ;Mark that we found at least one item Break ;Optimization: Break after finding the first item } - If !vCount ;Is vCount still zero (directory empty)? + If !dirHasItems ;Is directory empty? { FileCopyDir, %Quellpfad%, %Fullpath% MsgBox % "Copied " button.Name } - Else ;Otherwise vCount is NOT empty... + Else ;Otherwise directory is NOT empty... MsgBox % "Dir is not empty. Can't copy" } From 175dde94c0546a2bfba2218c4ba02b90c0475d75 Mon Sep 17 00:00:00 2001 From: Ven0m0 Date: Tue, 10 Feb 2026 11:20:31 +0100 Subject: [PATCH 4/4] Update optimize_script.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- optimize_script.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/optimize_script.py b/optimize_script.py index 3d964ce..95cfe19 100644 --- a/optimize_script.py +++ b/optimize_script.py @@ -1,5 +1,3 @@ -import sys - file_path = "Other/Citra_mods/Citra_Mod_Manager.ahk" with open(file_path, "r") as f: