You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
isValidINIFilename: replace manual character-by-character .ini extension check with AsciiString::endsWithNoCase, which is already used for the same purpose in loadFileDirectory
loadDirectory: remove a try/catch that only rethrew — identical behavior to no try/catch since there was no cleanup or transformation in the catch body
scanLookupList: remove unreachable found = true; break; lines that appeared after a return statement
This PR makes three independent dead-code and redundancy cleanups to INI.cpp. The manual three-character extension check in isValidINIFilename is replaced with the free template function endsWithNoCase(filename, ".ini") from stringex.h, which is both cleaner and strictly more correct (the old code did not require the preceding dot). The no-op try { ... } catch (...) { throw; } wrapper in loadDirectory is removed with no behavioral change. The unreachable found = true; break; statements after an unconditional return in scanLookupList are deleted along with the now-unused Bool found variable. No regressions are introduced by any of the three changes.
Confidence Score: 5/5
Safe to merge — all three changes are correct refactors with equivalent or strictly better behavior.
All changes eliminate dead or redundant code. The only subtle semantic shift (isValidINIFilename now requires the dot before 'ini') is strictly more correct, and the function appears to have no live call sites. No P0 or P1 findings.
No files require special attention.
Important Files Changed
Filename
Overview
Core/GameEngine/Source/Common/INI/INI.cpp
Three cleanups: replace manual extension check with endsWithNoCase, remove no-op try/catch, remove unreachable post-return dead code
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[isValidINIFilename] -->|Old| B["Manual check: last 3 chars == 'ini' (no dot)"]
A -->|New| C["endsWithNoCase(filename, \".ini\") — includes dot, more correct"]
D[loadDirectory] -->|Old| E["try { ... } catch(...) { throw; } — no-op"]
D -->|New| F["Direct body — identical behavior, no wrapper"]
G[scanLookupList] -->|Old| H["return lookup->value; found=true; break; — unreachable"]
G -->|New| I["return lookup->value; — dead code removed"]
Four focused cleanups to INI.cpp: isValidINIFilename now uses endsWithNoCase(".ini") which is stricter than the old check (the old code accepted strings like xINI without a dot); the no-op try/catch in loadDirectory is removed; findBlockParse switches to binary search over the already-sorted theTypeTable; and unreachable dead code (found = true; break;) after return statements in scanLookupList is removed. All four changes are verified correct.
Confidence Score: 5/5
Safe to merge — all changes are correct refactors with no behavioral regressions
All four changes are verified correct: endsWithNoCase handles short strings safely, theTypeTable is sorted in strcmp order, the try/catch removal is semantically equivalent, and the dead-code removal is trivially safe. The only finding is a P2 style note about documenting the sort requirement for the binary search table.
No files require special attention
Important Files Changed
Filename Overview
Core/GameEngine/Source/Common/INI/INI.cpp Four clean refactors: stricter .ini filename validation, no-op try/catch removal, linear-to-binary-search for findBlockParse (table verified sorted), and dead-code removal after return statements
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[findBlockParse: token] --> B[Binary search theTypeTable]
B --> C{strcmp result?}
C -- zero: match --> D[Return parse function pointer]
C -- negative: table < token --> F[lo = mid + 1]
C -- positive: table > token --> E[hi = mid]
E --> B
F --> B
B -- lo >= hi: not found --> G[Return nullptr]
Loading
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Core/GameEngine/Source/Common/INI/INI.cpp
Line: 340-354
Comment:
**Binary search requires sorted table**
The binary search is correct as-is, but `theTypeTable` has no documentation requiring it to remain sorted. A future entry inserted in the wrong position would silently return `nullptr` for valid tokens, breaking INI parsing for those block types without any compile-time or run-time diagnostic. Adding a comment near the table definition stating that entries must be kept in `strcmp` (case-sensitive ASCII) order would prevent this silent failure mode.
How can I resolve this? If you propose a fix, please make it concise.
Fair, there's no guarantee for the sorting, and we could add an assert and/or a comment, but this is a small search and only happens once - not really worth changing, I reverted it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RefactorEdits the code with insignificant behavior changes, is never user facing
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three focused cleanups to
INI.cpp:isValidINIFilename: replace manual character-by-character.iniextension check withAsciiString::endsWithNoCase, which is already used for the same purpose inloadFileDirectoryloadDirectory: remove a try/catch that only rethrew — identical behavior to no try/catch since there was no cleanup or transformation in the catch bodyscanLookupList: remove unreachablefound = true; break;lines that appeared after areturnstatement