halostatue / minitar

Minimal pure-ruby support for POSIX tar(1) archives.
Other
38 stars 27 forks source link

No unnecessary strings on POSIX header creation #18

Closed halostatue closed 7 years ago

halostatue commented 7 years ago

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?)).

This commit tests the behaviour, but is probably not compatible with Ruby 1.8 versions.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.04%) to 79.576% when pulling 14a84f7718803de7662a17a5b4bec7b45e5206bd on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.1%) to 79.733% when pulling 143c03740efe4aee089ef8aba31e5a172a3f8003 on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.1%) to 79.733% when pulling 143c03740efe4aee089ef8aba31e5a172a3f8003 on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.1%) to 79.733% when pulling 143c03740efe4aee089ef8aba31e5a172a3f8003 on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.1%) to 79.733% when pulling 524fdd5a00aa7e65330066909167df470d927057 on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.1%) to 79.733% when pulling 524fdd5a00aa7e65330066909167df470d927057 on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.4%) to 80.043% when pulling 0186906962a76d88381846b007c8ffc286f9341d on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.4%) to 80.043% when pulling 0186906962a76d88381846b007c8ffc286f9341d on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.4%) to 80.043% when pulling 8ce5a77217e809b21dcf491e23664ba7c3079c49 on test-changes-and-more-bug-fixes into a485f960307bbc3a2305469aece99dd73778fe72 on master.