diff --git a/dpa/set-and-map.c b/dpa/set-and-map2.c index 863961e..66d63e5 100644 --- a/dpa/set-and-map.c +++ b/dpa/set-and-map2.c @@ -5300,33 +5300,27 @@ dpa_u_unsequenced static inline unsigned dpa_u_map_u_unhash_sub(unsigned x){ return (unsigned)(x * dpa__u_choose_prime_inverse(unsigned)); #pragma GCC diagnostic pop } -static struct lookup_result dpa_u_map_u_lookup_sub( +__attribute__((always_inline)) static inline struct lookup_result dpa_u_map_u_lookup_sub( const dpa_u_map_u_t*restrict const that, const unsigned key, const size_t lbsize ){ - const size_t mask = (((size_t)1)<> shift; + unsigned i = (key)+I; if(!that->key_list) - return (struct lookup_result){i, false}; + return (struct lookup_result){i>>shift,0}; unsigned hash = (key); - // Note: this is actually inverted. The real PSL is ~psl_a>>shift and ~psl_b>>shift. - unsigned psl_a = hash - ((unsigned)i<key_list[i]; - unsigned psl_b = (ekey) - ((unsigned)i<key_list[i>>shift]) - i - 1; + if(psl_a <= (unsigned)(psl_b)) + break; psl_a -= I; - i = (i+1) & mask; + i += I; } - dpa_u_unreachable("Hashmap lookup failed: %s", "That neither an entry is found, nor the PSL ever exceeds the one of any of the entries of the hashmap while earching, should not be possible."); + return (struct lookup_result){i>>shift, psl_b == psl_a}; } // This subroutine is used after an existing value was already found, so we have the index of where to insert it. static void dpa_u_map_u_insert_sub( @@ -5709,7 +5703,7 @@ dpa__u_api dpa_u_optional_pointer_t dpa_u_map_u_get(const dpa_u_map_u_t* that, u if(!that->count) return (dpa_u_optional_pointer_t){0}; const unsigned entry = dpa_u_map_u_hash_sub(key); - if(that->lbsize == sizeof(unsigned)*CHAR_BIT){ + if(dpa_u_unlikely(that->lbsize == sizeof(unsigned)*CHAR_BIT)){ const dpa_u_bitmap_entry_t*restrict const m = &that->bitmask[DPA__U_SM_BITMAP_OFFSET(entry)]; dpa_u_bitmap_entry_t s = DPA__U_SM_BITMAP_BIT(entry); if(!(*m&s))