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

Reduce file descriptor consumption #59

Merged
merged 3 commits into from
Sep 9, 2021
Merged

Reduce file descriptor consumption #59

merged 3 commits into from
Sep 9, 2021

Conversation

bsneed
Copy link
Contributor

@bsneed bsneed commented Sep 9, 2021

Reduces file descriptor usage by storing file handle rather than opening a new one with every write.

fileHandle?.seekToEndOfFile()
// prepare for the next entry
if newFile == false {
fileHandle?.write(",".data(using: .utf8)!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we absolutely know 100% of the time this explicit will work on all platforms? Makes me uneasy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it not work on all platforms?? It's almost identical to what it was before and tests are passing hunky dory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it just being a comma should be okay.

assert(false, "Storage: failed to write event to \(storeFile), error: \(error)")
// write the data
fileHandle?.write(jsonData)
if #available(tvOS 13, *) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to add a comment why we are doing this for 13 and above but supporting 11.

@bsneed bsneed merged commit 74839c7 into main Sep 9, 2021
@bsneed bsneed deleted the bsneed/fileio branch September 9, 2021 17:54
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