@@ -80,7 +80,7 @@ void hashmap_set_load_factor(struct hashmap *map, double factor) {
8080}
8181
8282static struct bucket * bucket_at0 (void * buckets , size_t bucketsz , size_t i ) {
83- return (struct bucket * )((( char * )buckets ) + (bucketsz * i ));
83+ return (struct bucket * )((uintptr_t )buckets + (bucketsz * i ));
8484}
8585
8686static struct bucket * bucket_at (const struct hashmap * map , size_t index ) {
@@ -571,145 +571,6 @@ static uint64_t SIP64(const uint8_t *in, const size_t inlen, uint64_t seed0,
571571 return out ;
572572}
573573
574- //-----------------------------------------------------------------------------
575- // MurmurHash3 was written by Austin Appleby, and is placed in the public
576- // domain. The author hereby disclaims copyright to this source code.
577- //
578- // Murmur3_86_128
579- //-----------------------------------------------------------------------------
580- static uint64_t MM86128 (const void * key , const int len , uint32_t seed ) {
581- #define ROTL32 (x , r ) ((x << r) | (x >> (32 - r)))
582- #define FMIX32 (h ) \
583- h ^= h >> 16; \
584- h *= 0x85ebca6b; \
585- h ^= h >> 13; \
586- h *= 0xc2b2ae35; \
587- h ^= h >> 16;
588- const uint8_t * data = (const uint8_t * )key ;
589- const int nblocks = len / 16 ;
590- uint32_t h1 = seed ;
591- uint32_t h2 = seed ;
592- uint32_t h3 = seed ;
593- uint32_t h4 = seed ;
594- uint32_t c1 = 0x239b961b ;
595- uint32_t c2 = 0xab0e9789 ;
596- uint32_t c3 = 0x38b34ae5 ;
597- uint32_t c4 = 0xa1e38b93 ;
598- const uint32_t * blocks = (const uint32_t * )(data + nblocks * 16 );
599- for (int i = - nblocks ; i ; i ++ ) {
600- uint32_t k1 = blocks [i * 4 + 0 ];
601- uint32_t k2 = blocks [i * 4 + 1 ];
602- uint32_t k3 = blocks [i * 4 + 2 ];
603- uint32_t k4 = blocks [i * 4 + 3 ];
604- k1 *= c1 ;
605- k1 = ROTL32 (k1 , 15 );
606- k1 *= c2 ;
607- h1 ^= k1 ;
608- h1 = ROTL32 (h1 , 19 );
609- h1 += h2 ;
610- h1 = h1 * 5 + 0x561ccd1b ;
611- k2 *= c2 ;
612- k2 = ROTL32 (k2 , 16 );
613- k2 *= c3 ;
614- h2 ^= k2 ;
615- h2 = ROTL32 (h2 , 17 );
616- h2 += h3 ;
617- h2 = h2 * 5 + 0x0bcaa747 ;
618- k3 *= c3 ;
619- k3 = ROTL32 (k3 , 17 );
620- k3 *= c4 ;
621- h3 ^= k3 ;
622- h3 = ROTL32 (h3 , 15 );
623- h3 += h4 ;
624- h3 = h3 * 5 + 0x96cd1c35 ;
625- k4 *= c4 ;
626- k4 = ROTL32 (k4 , 18 );
627- k4 *= c1 ;
628- h4 ^= k4 ;
629- h4 = ROTL32 (h4 , 13 );
630- h4 += h1 ;
631- h4 = h4 * 5 + 0x32ac3b17 ;
632- }
633- const uint8_t * tail = (const uint8_t * )(data + nblocks * 16 );
634- uint32_t k1 = 0 ;
635- uint32_t k2 = 0 ;
636- uint32_t k3 = 0 ;
637- uint32_t k4 = 0 ;
638- switch (len & 15 ) {
639- case 15 :
640- k4 ^= tail [14 ] << 16 ; /* fall through */
641- case 14 :
642- k4 ^= tail [13 ] << 8 ; /* fall through */
643- case 13 :
644- k4 ^= tail [12 ] << 0 ;
645- k4 *= c4 ;
646- k4 = ROTL32 (k4 , 18 );
647- k4 *= c1 ;
648- h4 ^= k4 ;
649- /* fall through */
650- case 12 :
651- k3 ^= tail [11 ] << 24 ; /* fall through */
652- case 11 :
653- k3 ^= tail [10 ] << 16 ; /* fall through */
654- case 10 :
655- k3 ^= tail [9 ] << 8 ; /* fall through */
656- case 9 :
657- k3 ^= tail [8 ] << 0 ;
658- k3 *= c3 ;
659- k3 = ROTL32 (k3 , 17 );
660- k3 *= c4 ;
661- h3 ^= k3 ;
662- /* fall through */
663- case 8 :
664- k2 ^= tail [7 ] << 24 ; /* fall through */
665- case 7 :
666- k2 ^= tail [6 ] << 16 ; /* fall through */
667- case 6 :
668- k2 ^= tail [5 ] << 8 ; /* fall through */
669- case 5 :
670- k2 ^= tail [4 ] << 0 ;
671- k2 *= c2 ;
672- k2 = ROTL32 (k2 , 16 );
673- k2 *= c3 ;
674- h2 ^= k2 ;
675- /* fall through */
676- case 4 :
677- k1 ^= tail [3 ] << 24 ; /* fall through */
678- case 3 :
679- k1 ^= tail [2 ] << 16 ; /* fall through */
680- case 2 :
681- k1 ^= tail [1 ] << 8 ; /* fall through */
682- case 1 :
683- k1 ^= tail [0 ] << 0 ;
684- k1 *= c1 ;
685- k1 = ROTL32 (k1 , 15 );
686- k1 *= c2 ;
687- h1 ^= k1 ;
688- /* fall through */
689- };
690- h1 ^= len ;
691- h2 ^= len ;
692- h3 ^= len ;
693- h4 ^= len ;
694- h1 += h2 ;
695- h1 += h3 ;
696- h1 += h4 ;
697- h2 += h1 ;
698- h3 += h1 ;
699- h4 += h1 ;
700- FMIX32 (h1 );
701- FMIX32 (h2 );
702- FMIX32 (h3 );
703- FMIX32 (h4 );
704- h1 += h2 ;
705- h1 += h3 ;
706- h1 += h4 ;
707- h2 += h1 ;
708- h3 += h1 ;
709- h4 += h1 ;
710- return (((uint64_t )h2 ) << 32 ) | h1 ;
711- }
712-
713574//-----------------------------------------------------------------------------
714575// xxHash Library
715576// Copyright (c) 2012-2021 Yann Collet
@@ -842,13 +703,6 @@ uint64_t hashmap_sip(const void *data, size_t len, uint64_t seed0,
842703 return SIP64 ((const uint8_t * )data , len , seed0 , seed1 );
843704}
844705
845- // hashmap_murmur returns a hash value for `data` using Murmur3_86_128.
846- uint64_t hashmap_murmur (const void * data , size_t len , uint64_t seed0 ,
847- uint64_t seed1 ) {
848- (void )seed1 ;
849- return MM86128 (data , len , seed0 );
850- }
851-
852706uint64_t hashmap_xxhash3 (const void * data , size_t len , uint64_t seed0 ,
853707 uint64_t seed1 ) {
854708 (void )seed1 ;
0 commit comments