copy,dd: simplify and optimize NUL bytes detection
commit9459d9d8112fe7816022665b5016c2014bb625f3
authorPádraig Brady <P@draigBrady.com>
Thu, 22 Oct 2015 13:34:08 +0000 (22 14:34 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 27 Oct 2015 17:25:12 +0000 (27 17:25 +0000)
tree80486d9f4331e149f6e7ef7381acbac1613ffb31
parent6796698c9945d87236ffcc939137d0919ef04931
copy,dd: simplify and optimize NUL bytes detection

* src/factor.c: Move LIKELY() definition to...
* src/system.h: ...here.
(is_nul): Reimplement with a version that doesn't
require a sentinel after the buffer, and which calls
down to (the system optimized) memcmp.
Performance analyzed at http://rusty.ozlabs.org/?p=560
* src/dd.c (alloc_obuf): Simplify the is_nul() call by
not needing to write the sentinel.
* src/copy.c (sparse_copy): Likewise.
(copy_reg): Simplify the buffer allocation by avoiding
consideration of the sentinel in the buffer size calculation.
src/copy.c
src/dd.c
src/factor.c
src/system.h