-
Notifications
You must be signed in to change notification settings - Fork 1
⚡ Optimize Citra config updates to single-pass parsing #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fadc812
95003ec
9b3a7fc
196c491
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,20 +53,30 @@ ScanMods(){ | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ;----------------- Config Helpers ----------------- | ||||||||||||||||||||||||||
| RegExEscape(str){ | ||||||||||||||||||||||||||
| static specials := "()[]{}?*+|^$.\" | ||||||||||||||||||||||||||
| out := "" | ||||||||||||||||||||||||||
| Loop, Parse, str | ||||||||||||||||||||||||||
| out .= InStr(specials, A_LoopField) ? "\" A_LoopField : A_LoopField | ||||||||||||||||||||||||||
| return out | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| UpdateConfig(content, updates){ | ||||||||||||||||||||||||||
| newContent := "" | ||||||||||||||||||||||||||
| remaining := updates.Clone() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||
|
Comment on lines
+67
to
+68
|
||||||||||||||||||||||||||
| remaining.Delete(keyCandidate) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+65
to
+70
|
||||||||||||||||||||||||||
| keyCandidate := RTrim(SubStr(line, 1, pos-1)) | |
| if (remaining.HasKey(keyCandidate)){ | |
| val := remaining[keyCandidate] | |
| line := keyCandidate "=" val | |
| remaining.Delete(keyCandidate) | |
| } | |
| keyCandidate := RTrim(SubStr(line, 1, pos-1)) | |
| if (remaining.HasKey(keyCandidate)){ | |
| val := remaining[keyCandidate] | |
| line := keyCandidate "=" val | |
| remaining.Delete(keyCandidate) | |
| } |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Loop Parse delimiter n with r stripped will normalize line endings to LF only (Unix-style), but the function then appends "n" (LF) to each line. This means the output will have LF line endings regardless of what the input file had. If the original qt-config.ini uses CRLF line endings (Windows standard), this changes the file format. Consider preserving the original line ending style or explicitly using CRLF ("r`n") for Windows compatibility, as specified in the repository's coding guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
RTrimhere only removes whitespace from the right side of the key. If a key in the configuration file has leading whitespace (e.g.,key = value), it will be parsed incorrectly as" key", and the update for"key"will be missed. UsingTriminstead will handle both leading and trailing whitespace, making the parsing more robust to formatting variations in the config file.