On Fri, 05 Aug 2011 18:43:27 +0200, Kai Meyer <k...@unixlords.com> wrote:
On 08/05/2011 03:02 AM, Pelle wrote:
Don't declare variables until you need them, just leave bytes_read and
bytes_max here.
Is there a performance consideration? Or is it purely a style or
D-Factor suggestion?
Just style and D-factor :-)
Also, resulting code is shorter, and you can replace a lot of type names
with auto.
I don't understand why you use ByteUnion instead of just a plain array
of bytes.
I thought that comparing one byte at a time would be slower than
comparing 8 bytes at a time (size_t on 64bit) and failing over to the
byte-by-byte comparison only when the size_t value was different.
Maybe, but that's something that should be benchmarked. If a byte array is
just as fast, and the code is simpler, that's a better solution :)