commit 400454f5963c78743120a031237ed0aec2e05995 parent 6a52f454ea2c0970ad031cde04df499435574a42 Author: Michael Savage <mikejsavage@gmail.com> Date: Tue, 24 Oct 2017 20:06:36 +0300 More FNV fixes Diffstat:
fnv.h | | | 8 | ++++++-- |
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fnv.h b/fnv.h @@ -4,9 +4,13 @@ #include "array.h" forceinline u64 fnv1a( const void * data, size_t n ) { - u64 hash = U64( 14695981039346656037 ); + const u64 basis = U64( 14695981039346656037 ); + const u64 prime = U64( 1099511628211 ); + + const char * cdata = ( const char * ) data; + u64 hash = basis; for( size_t i = 0; i < n; i++ ) { - hash = ( hash * U64( 1099511628211 ) ) ^ data[ i ]; + hash = ( hash ^ cdata[ i ] ) * prime; } return hash; }