Conversation
This new version is based on the assumption that the majority of case errors will occur at the end of the given path and uses this as an optimization opportunity. Since the start of the path is provided by the engine, this appears to be a very safe assumption-.
|
I tested this patch on linux. Loading levels has accelerated 10 times. You should definitely accept this PR. |
Contributor
|
Confirm. Even on my e2k-Linux, loading levels has become much faster than it was without this patch. |
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.
The existing case-correction algorithm performs an
access-check on every path component -- this results in a lot of redundant syscalls, since the majority of the path is provided by the engine and should thus be already correct.This new version instead scans the path backwards, looking for the first incorrect component from the end of the path, correcting it, and then working forward from there (in a similar manner to the old version).
On my setup, this significantly improves loading performance, especially when reloading the game data after regaining focus. Without this patch, the game would often spend several seconds reloading assets; with the patch applied, the game becomes responsive within less than 1 second.
I've verified that the main campaign works with these changes applied.
If there are any code-style issues or similar, I'd be happy to correct them.
The diff might look a bit odd due to how git has decided to match things -- the
std::string caseCorrect(const std::string &path)overload has not been modified; only thevoid caseCorrect(char* path)function was replaced (alongside a fewstaticfunctions).