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

No unnecessary strings on POSIX header creation #19

Merged
merged 1 commit into from Nov 8, 2016

Conversation

halostatue
Copy link
Owner

The POSIX header creation methods created a new 512-byte string of NULL
bytes just to see if the header was an empty header. This could be simplified
with a single 512-byte constant string for comparison, but a short-circuiting
comparison will be more efficient over-all. Use the #each_byte enumerator with
the #any? test method on #nonzero? (data.each_byte.any?(&:nonzero?)).

@halostatue halostatue self-assigned this Nov 8, 2016
@coveralls
Copy link

coveralls commented Nov 8, 2016

Coverage Status

Coverage increased (+0.4%) to 80.043% when pulling 14d7c08 on stop-creating-unnecessary-strings into a485f96 on master.

The POSIX header creation methods created a new 512-byte string of NULL
bytes just to see if the header was an empty header. This could be simplified
with a single 512-byte constant string for comparison, but a short-circuiting
comparison will be more efficient over-all. Use the #each_byte enumerator with
the #any? test method on #nonzero? (data.each_byte.any?(&:nonzero?)).
@halostatue halostatue force-pushed the stop-creating-unnecessary-strings branch from 14d7c08 to d2a025f Compare November 8, 2016 19:23
@coveralls
Copy link

coveralls commented Nov 8, 2016

Coverage Status

Coverage increased (+0.6%) to 80.196% when pulling d2a025f on stop-creating-unnecessary-strings into a485f96 on master.

@halostatue halostatue merged commit 27569df into master Nov 8, 2016
@halostatue halostatue deleted the stop-creating-unnecessary-strings branch November 8, 2016 19:39
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

2 participants