News for hackers. Stuff that matters.
Re:Perfect Hashes and faster than memcmp by userbinator on Thursday March 19, 2015 @09:19AM (#9231650)
we can optimize memcmp away by doing word-size comparison directly. This is 50% - 2000% faster then doing memcmp on each string

This is what a good implementation of memcmp would do anyway (and on x86, one may compare up to 16 bytes at once using SSE), but the problem is that memcmp is generic enough that it must work for all lengths so for short comparisons you lose more cycles in switching between all the special cases than is gained from the comparison itself.

There are no comments on this comment yet.