… | |
… | |
573 | // FNV-1a is faster on many cpus because the multiplication |
573 | // FNV-1a is faster on many cpus because the multiplication |
574 | // runs concurrently with the looping logic. |
574 | // runs concurrently with the looping logic. |
575 | uint32_t hash = STRHSH_NULL; |
575 | uint32_t hash = STRHSH_NULL; |
576 | |
576 | |
577 | while (*s) |
577 | while (*s) |
578 | hash = (hash ^ *s++) * 16777619; |
578 | hash = (hash ^ *s++) * 16777619U; |
579 | |
579 | |
580 | return hash; |
580 | return hash; |
581 | } |
581 | } |
582 | |
582 | |
583 | static inline uint32_t |
583 | static inline uint32_t |
584 | memhsh (const char *s, size_t len) |
584 | memhsh (const char *s, size_t len) |
585 | { |
585 | { |
586 | uint32_t hash = STRHSH_NULL; |
586 | uint32_t hash = STRHSH_NULL; |
587 | |
587 | |
588 | while (len--) |
588 | while (len--) |
589 | hash = (hash ^ *s++) * 16777619; |
589 | hash = (hash ^ *s++) * 16777619U; |
590 | |
590 | |
591 | return hash; |
591 | return hash; |
592 | } |
592 | } |
593 | |
593 | |
594 | struct str_hash |
594 | struct str_hash |