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

Add oZFile_fwrite method #4

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

Conversation

ahl27
Copy link

@ahl27 ahl27 commented Dec 20, 2024

Adds analogous fwrite method for oZFile accessors. fwrite tends to be slightly faster than puts since it doesn't have to check every character for '\0', which allows for some OS optimization. Would be useful to use in Biostrings for writeXStringSet since the write size of blocks are known in advance, so appending '\0' and then asking the OS to check for it is overkill.

Function arguments follow conventions of the other oZFile* functions despite differing from fwrite argument syntax.

gzfwrite is defined here:

https://github.com/madler/zlib/blob/ef24c4c7502169f016dcd2a26923dbaf3216748c/gzwrite.c#L260-L262

Header definition is here:

https://github.com/madler/zlib/blob/ef24c4c7502169f016dcd2a26923dbaf3216748c/zlib.h#L1472-L1473

I moved the n==nitems check to the end of the switch case because I find it significantly more readable than the alternative in oZFile_puts.

@ahl27 ahl27 changed the title Add oZFile_fwrite method Add oZFile_fwrite method Dec 20, 2024
@ahl27
Copy link
Author

ahl27 commented Dec 20, 2024

force pushes are some minor commit amends

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.

1 participant