StronglyUniversalStringHashing icon indicating copy to clipboard operation
StronglyUniversalStringHashing copied to clipboard

Word Padding could be improved

Open lemire opened this issue 8 years ago • 0 comments

This is clever code that could be put to good use:

char * s =... // null terminated string
uint64_t c = *( uint64_t *) (s);
uint64_t zero_mask = (c - 0x0101010101010101) & ~c & 0x8080808080808080;
uint64_t string_mask = zero_mask ^ (zero_mask - 1);
c &= string_mask;

credit: Kendall Willets.

lemire avatar Nov 16 '17 00:11 lemire