ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.111 by root, Tue Jul 6 20:00:46 2010 UTC vs.
Revision 1.112 by root, Tue Jul 6 20:15:13 2010 UTC

511 // use FNV-1a hash (http://isthe.com/chongo/tech/comp/fnv/) 511 // use FNV-1a hash (http://isthe.com/chongo/tech/comp/fnv/)
512 // it is about twice as fast as the one-at-a-time one, 512 // it is about twice as fast as the one-at-a-time one,
513 // with good distribution. 513 // with good distribution.
514 // FNV-1a is faster on many cpus because the multiplication 514 // FNV-1a is faster on many cpus because the multiplication
515 // runs concurrently with the looping logic. 515 // runs concurrently with the looping logic.
516 // we modify the hash a bit to improve its distribution
516 uint32_t hash = STRHSH_NULL; 517 uint32_t hash = STRHSH_NULL;
517 518
518 while (*s) 519 while (*s)
519 hash = (hash ^ *s++) * 16777619U; 520 hash = (hash ^ *s++) * 16777619U;
520 521
521 return hash; 522 return hash ^ (hash >> 16);
522} 523}
523 524
524static inline uint32_t 525static inline uint32_t
525memhsh (const char *s, size_t len) 526memhsh (const char *s, size_t len)
526{ 527{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines