Skip to content
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

Replace UNIX Case Correction #113

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Fayti1703
Copy link

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 the void caseCorrect(char* path) function was replaced (alongside a few static functions).

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-.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant