Skip to content

Avoid reopening file on every FileIO read/write#115

Open
flyngmt wants to merge 1 commit intoencounter:mainfrom
flyngmt:fix/card-fileio-improvement
Open

Avoid reopening file on every FileIO read/write#115
flyngmt wants to merge 1 commit intoencounter:mainfrom
flyngmt:fix/card-fileio-improvement

Conversation

@flyngmt
Copy link
Copy Markdown

@flyngmt flyngmt commented Apr 10, 2026

FileIO::fileRead/fileWrite open and close the file on every call, which causes noticeable slowdowns on Card::format().

Takes like a minute on an HDD and 10-15 seconds on an SSD to create the .raw file on the initial run, fixes that by just keeping the file open instead.

@encounter
Copy link
Copy Markdown
Owner

Thanks for the PR! It looks like this was explicitly introduced in #77 to avoid locking the file while the game was running. However, I agree that reopening the file on every write is not ideal. Maybe we can keep the file open only while actively writing to it, and close it afterwards.

@flyngmt
Copy link
Copy Markdown
Author

flyngmt commented Apr 10, 2026

I didn't realize it was such a new change, lol.

Yeah, that's probably the best way then. Current one helps the development but most end users will think game just crashed especially if they are using an HDD.

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.

2 participants