On 01/05/2017 08:10 AM, David Nicol wrote: > On Wed, Jan 4, 2017 at 11:48 PM, Karl Williamson > <public@khwilliamson.com> wrote: >> >> If we have a sequence that must all match, it seems to me we should be using >> memcmp() regardless of alignment. > > or at least crib its comparison method versus length heuristic (if any.) > > 16 bytes in glibc. Below that, and it does byte-by-byte comparisons. Above, and it goes byte-by-byte until at least one of the operands is aligned. It then calls separate sub-functions depending on if both or just one operand is aligned. I thought there might be some hardware support for this, but either I'm wrong, or don't know how or where to look for info about it. I'm tempted to write an inline memcmp and change the macros like memEQ, memGE to use it. It would loop if the length parameter is 16 or fewer bytes; otherwise call the real memcmp. I think Dave was considering something like this, but hadn't gotten around to benchmarking it.Thread Previous