perf(ini): Remove unnecessary strlen call in INI::readLine#2253
Open
Caball009 wants to merge 2 commits intoTheSuperHackers:mainfrom
Open
perf(ini): Remove unnecessary strlen call in INI::readLine#2253Caball009 wants to merge 2 commits intoTheSuperHackers:mainfrom
Caball009 wants to merge 2 commits intoTheSuperHackers:mainfrom
Conversation
Caball009
commented
Feb 3, 2026
Greptile Overview
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/Common/INI/INI.cpp | Optimizes INI line reading by eliminating strlen call; has format specifier bug that needs fixing |
Sequence Diagram
sequenceDiagram
participant Caller
participant ReadLine as INI readLine
participant Buffer as m_buffer
participant Xfer as s_xfer
Caller->>ReadLine: Read next line
activate ReadLine
ReadLine->>ReadLine: Initialize lineLength = 0
alt End of file
ReadLine->>Buffer: Set to empty string
else Normal reading
loop Until newline or buffer full
ReadLine->>Buffer: Read character from file
alt Character is semicolon
ReadLine->>Buffer: Terminate string at semicolon
ReadLine->>ReadLine: Save lineLength before semicolon
ReadLine->>ReadLine: Continue reading comment
else Character is newline
ReadLine->>Buffer: Terminate string
ReadLine->>ReadLine: Break loop
else Character is whitespace
ReadLine->>Buffer: Convert to space
end
end
ReadLine->>Buffer: Final null termination
alt lineLength not yet set
ReadLine->>ReadLine: Calculate lineLength from pointer
else lineLength is empty line marker
ReadLine->>ReadLine: Set lineLength = 0
end
end
alt CRC transfer enabled
ReadLine->>ReadLine: Assert lineLength equals strlen
ReadLine->>Xfer: Transfer buffer with computed length
Note over Xfer: CRC computed without strlen call
end
ReadLine-->>Caller: Line ready
deactivate ReadLine
xezon
reviewed
Feb 4, 2026
xezon
left a comment
There was a problem hiding this comment.
This adds a lot of extra complexity that is more prone to errors than the strlen was. Is it worth it? Can it be simplified?
Author
|
I think I feel the same way about it as you do. The first iteration of this PR was much simpler but ignored the comment logic for |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR removes an unnecessary call to
strleninINI::readLinethat was used for the CRC computation. The line length can be tracked while parsing the line.