refactor(ini): Clean up INI type table and its search logic#2511
refactor(ini): Clean up INI type table and its search logic#2511xezon merged 3 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/Common/INI/INI.cpp | Alphabetically sorted theTypeTable, removed null sentinel entry, and updated findBlockParse to use ARRAY_SIZE-bounded loop — all changes are correct and safe. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["findBlockParse(token)"] --> B["Loop: i = 0 to ARRAY_SIZE(theTypeTable)-1"]
B --> C{"strcmp(theTypeTable[i].token, token) == 0?"}
C -- Yes --> D["return theTypeTable[i].parse"]
C -- No --> E{"i < ARRAY_SIZE?"}
E -- Yes --> B
E -- No --> F["return nullptr"]
Reviews (1): Last reviewed commit: "Simplified loop logic." | Re-trigger Greptile
xezon
left a comment
There was a problem hiding this comment.
Looks reasonable. Why is this labeled as performance? If you want to optimize lookups, perhaps make a change where the type table is accessible with a map.
|
I used the performance tag because I noticed a tiny but negligible improvement with the refactor. I removed the performance tag because it's not worth mentioning. I saw a small but negligible improvement with a map for release build, but a much bigger regression for debug build. So I will just keep the linear search. |
This PR cleans up
theTypeTableand puts it in alphabetical order. It also changes the loop logic, so that the last value doesn't need to be a sentinel value for the loop logic.See commits for a cleaner diff.