Skip to content

Replace UNIX Case Correction - #113

Open
Fayti1703 wants to merge 2 commits into
WolfireGames:mainfrom
Fayti1703:patch-case-correct
Open

Fayti1703 wants to merge 2 commits into
WolfireGames:mainfrom
Fayti1703:patch-case-correct

Conversation

@Fayti1703

Copy link
Copy Markdown
Contributor

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-.
@DJs3000

DJs3000 commented Feb 19, 2025

Copy link
Copy Markdown

I tested this patch on linux. Loading levels has accelerated 10 times. You should definitely accept this PR.

@r-a-sattarov

Copy link
Copy Markdown
Contributor

Confirm. Even on my e2k-Linux, loading levels has become much faster than it was without this patch.

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.

3 participants