authorgravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-07-06 00:57:46-05:00
committergravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-07-06 00:57:46-05:00
logf02ee7a9f5a72f24a645f36db7ae7828f29d3393
tree36be57235e8deeee673e6e58395f1ae7280a8cd4
parent149ecdfe1b5149c46a58dffe670b36319983ad7f

Avoid some large copies for another second of time saved


5 files changed, 145 insertions(+), 115 deletions(-)

src/stage1/all_types.hpp+4-4
...@@ -1879,8 +1879,8 @@ struct TypeId {...@@ -1879,8 +1879,8 @@ struct TypeId {
1879 } data;1879 } data;
1880};1880};
18811881
1882uint32_t type_id_hash(TypeId);1882uint32_t type_id_hash(TypeId const *);
1883bool type_id_eql(TypeId a, TypeId b);1883bool type_id_eql(TypeId const *a, TypeId const *b);
18841884
1885enum ZigLLVMFnId {1885enum ZigLLVMFnId {
1886 ZigLLVMFnIdCtz,1886 ZigLLVMFnIdCtz,
...@@ -1935,8 +1935,8 @@ struct ZigLLVMFnKey {...@@ -1935,8 +1935,8 @@ struct ZigLLVMFnKey {
1935 } data;1935 } data;
1936};1936};
19371937
1938uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey);1938uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey const *);
1939bool zig_llvm_fn_key_eql(ZigLLVMFnKey a, ZigLLVMFnKey b);1939bool zig_llvm_fn_key_eql(ZigLLVMFnKey const *a, ZigLLVMFnKey const *b);
19401940
1941struct TimeEvent {1941struct TimeEvent {
1942 double time;1942 double time;
src/stage1/analyze.cpp+96-92
...@@ -7742,9 +7742,9 @@ ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {...@@ -7742,9 +7742,9 @@ ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
7742 return entry;7742 return entry;
7743}7743}
77447744
7745uint32_t type_id_hash(TypeId x) {7745uint32_t type_id_hash(TypeId const *x) {
7746 uint32_t hash = hash_combine(HASH_INIT, &x.id);7746 uint32_t hash = hash_combine(HASH_INIT, &x->id);
7747 switch (x.id) {7747 switch (x->id) {
7748 case ZigTypeIdInvalid:7748 case ZigTypeIdInvalid:
7749 case ZigTypeIdOpaque:7749 case ZigTypeIdOpaque:
7750 case ZigTypeIdMetaType:7750 case ZigTypeIdMetaType:
...@@ -7768,46 +7768,50 @@ uint32_t type_id_hash(TypeId x) {...@@ -7768,46 +7768,50 @@ uint32_t type_id_hash(TypeId x) {
7768 case ZigTypeIdAnyFrame:7768 case ZigTypeIdAnyFrame:
7769 zig_unreachable();7769 zig_unreachable();
7770 case ZigTypeIdErrorUnion:7770 case ZigTypeIdErrorUnion:
7771 hash = hash_combine(hash, &x.data.error_union.err_set_type);7771 hash = hash_combine(hash, &x->data.error_union.err_set_type);
7772 hash = hash_combine(hash, &x.data.error_union.payload_type);7772 hash = hash_combine(hash, &x->data.error_union.payload_type);
7773 return hash;7773 return hash;
7774 case ZigTypeIdPointer:7774 case ZigTypeIdPointer:
7775 hash = hash_combine(hash, &x.data.pointer.child_type);7775 hash = hash_combine(hash, &x->data.pointer.child_type);
7776 hash = hash_combine(hash, &x.data.pointer.ptr_len);7776 hash = hash_combine(hash, &x->data.pointer.ptr_len);
7777 hash = hash_combine(hash, &x.data.pointer.is_const);7777 hash = hash_combine(hash, &x->data.pointer.is_const);
7778 hash = hash_combine(hash, &x.data.pointer.is_volatile);7778 hash = hash_combine(hash, &x->data.pointer.is_volatile);
7779 hash = hash_combine(hash, &x.data.pointer.allow_zero);7779 hash = hash_combine(hash, &x->data.pointer.allow_zero);
7780 hash = hash_combine(hash, &x.data.pointer.alignment);7780 hash = hash_combine(hash, &x->data.pointer.alignment);
7781 hash = hash_combine(hash, &x.data.pointer.bit_offset_in_host);7781 hash = hash_combine(hash, &x->data.pointer.bit_offset_in_host);
7782 hash = hash_combine(hash, &x.data.pointer.vector_index);7782 hash = hash_combine(hash, &x->data.pointer.vector_index);
7783 hash = hash_combine(hash, &x.data.pointer.host_int_bytes);7783 hash = hash_combine(hash, &x->data.pointer.host_int_bytes);
7784 if (x.data.pointer.sentinel != nullptr) {7784 if (x->data.pointer.sentinel != nullptr) {
7785 hash = hash_combine_const_val(hash, x.data.pointer.sentinel);7785 hash = hash_combine_const_val(hash, x->data.pointer.sentinel);
7786 }
7787 if (x->data.pointer.inferred_struct_field) {
7788 hash = hash_combine(hash, &x->data.pointer.inferred_struct_field->inferred_struct_type);
7789 hash = hash_combine_buf(hash, x->data.pointer.inferred_struct_field->field_name);
7786 }7790 }
7787 return hash;7791 return hash;
7788 case ZigTypeIdArray:7792 case ZigTypeIdArray:
7789 hash = hash_combine(hash, &x.data.array.child_type);7793 hash = hash_combine(hash, &x->data.array.child_type);
7790 hash = hash_combine(hash, &x.data.array.size);7794 hash = hash_combine(hash, &x->data.array.size);
7791 if (x.data.array.sentinel != nullptr) {7795 if (x->data.array.sentinel != nullptr) {
7792 hash = hash_combine_const_val(hash, x.data.array.sentinel);7796 hash = hash_combine_const_val(hash, x->data.array.sentinel);
7793 }7797 }
7794 return hash;7798 return hash;
7795 case ZigTypeIdInt:7799 case ZigTypeIdInt:
7796 hash = hash_combine(hash, &x.data.integer.is_signed);7800 hash = hash_combine(hash, &x->data.integer.is_signed);
7797 hash = hash_combine(hash, &x.data.integer.bit_count);7801 hash = hash_combine(hash, &x->data.integer.bit_count);
7798 return hash;7802 return hash;
7799 case ZigTypeIdVector:7803 case ZigTypeIdVector:
7800 hash = hash_combine(hash, &x.data.vector.elem_type);7804 hash = hash_combine(hash, &x->data.vector.elem_type);
7801 hash = hash_combine(hash, &x.data.vector.len);7805 hash = hash_combine(hash, &x->data.vector.len);
7802 return hash;7806 return hash;
7803 }7807 }
7804 zig_unreachable();7808 zig_unreachable();
7805}7809}
78067810
7807bool type_id_eql(TypeId a, TypeId b) {7811bool type_id_eql(TypeId const *a, TypeId const *b) {
7808 if (a.id != b.id)7812 if (a->id != b->id)
7809 return false;7813 return false;
7810 switch (a.id) {7814 switch (a->id) {
7811 case ZigTypeIdInvalid:7815 case ZigTypeIdInvalid:
7812 case ZigTypeIdMetaType:7816 case ZigTypeIdMetaType:
7813 case ZigTypeIdVoid:7817 case ZigTypeIdVoid:
...@@ -7831,107 +7835,107 @@ bool type_id_eql(TypeId a, TypeId b) {...@@ -7831,107 +7835,107 @@ bool type_id_eql(TypeId a, TypeId b) {
7831 case ZigTypeIdAnyFrame:7835 case ZigTypeIdAnyFrame:
7832 zig_unreachable();7836 zig_unreachable();
7833 case ZigTypeIdErrorUnion:7837 case ZigTypeIdErrorUnion:
7834 return a.data.error_union.err_set_type == b.data.error_union.err_set_type &&7838 return a->data.error_union.err_set_type == b->data.error_union.err_set_type &&
7835 a.data.error_union.payload_type == b.data.error_union.payload_type;7839 a->data.error_union.payload_type == b->data.error_union.payload_type;
78367840
7837 case ZigTypeIdPointer:7841 case ZigTypeIdPointer:
7838 return a.data.pointer.child_type == b.data.pointer.child_type &&7842 return a->data.pointer.child_type == b->data.pointer.child_type &&
7839 a.data.pointer.ptr_len == b.data.pointer.ptr_len &&7843 a->data.pointer.ptr_len == b->data.pointer.ptr_len &&
7840 a.data.pointer.is_const == b.data.pointer.is_const &&7844 a->data.pointer.is_const == b->data.pointer.is_const &&
7841 a.data.pointer.is_volatile == b.data.pointer.is_volatile &&7845 a->data.pointer.is_volatile == b->data.pointer.is_volatile &&
7842 a.data.pointer.allow_zero == b.data.pointer.allow_zero &&7846 a->data.pointer.allow_zero == b->data.pointer.allow_zero &&
7843 a.data.pointer.alignment == b.data.pointer.alignment &&7847 a->data.pointer.alignment == b->data.pointer.alignment &&
7844 a.data.pointer.bit_offset_in_host == b.data.pointer.bit_offset_in_host &&7848 a->data.pointer.bit_offset_in_host == b->data.pointer.bit_offset_in_host &&
7845 a.data.pointer.vector_index == b.data.pointer.vector_index &&7849 a->data.pointer.vector_index == b->data.pointer.vector_index &&
7846 a.data.pointer.host_int_bytes == b.data.pointer.host_int_bytes &&7850 a->data.pointer.host_int_bytes == b->data.pointer.host_int_bytes &&
7847 (7851 (
7848 a.data.pointer.sentinel == b.data.pointer.sentinel ||7852 a->data.pointer.sentinel == b->data.pointer.sentinel ||
7849 (a.data.pointer.sentinel != nullptr && b.data.pointer.sentinel != nullptr &&7853 (a->data.pointer.sentinel != nullptr && b->data.pointer.sentinel != nullptr &&
7850 const_values_equal(a.data.pointer.codegen, a.data.pointer.sentinel, b.data.pointer.sentinel))7854 const_values_equal(a->data.pointer.codegen, a->data.pointer.sentinel, b->data.pointer.sentinel))
7851 ) &&7855 ) &&
7852 (7856 (
7853 a.data.pointer.inferred_struct_field == b.data.pointer.inferred_struct_field ||7857 a->data.pointer.inferred_struct_field == b->data.pointer.inferred_struct_field ||
7854 (a.data.pointer.inferred_struct_field != nullptr &&7858 (a->data.pointer.inferred_struct_field != nullptr &&
7855 b.data.pointer.inferred_struct_field != nullptr &&7859 b->data.pointer.inferred_struct_field != nullptr &&
7856 a.data.pointer.inferred_struct_field->inferred_struct_type ==7860 a->data.pointer.inferred_struct_field->inferred_struct_type ==
7857 b.data.pointer.inferred_struct_field->inferred_struct_type &&7861 b->data.pointer.inferred_struct_field->inferred_struct_type &&
7858 buf_eql_buf(a.data.pointer.inferred_struct_field->field_name,7862 buf_eql_buf(a->data.pointer.inferred_struct_field->field_name,
7859 b.data.pointer.inferred_struct_field->field_name))7863 b->data.pointer.inferred_struct_field->field_name))
7860 );7864 );
7861 case ZigTypeIdArray:7865 case ZigTypeIdArray:
7862 return a.data.array.child_type == b.data.array.child_type &&7866 return a->data.array.child_type == b->data.array.child_type &&
7863 a.data.array.size == b.data.array.size &&7867 a->data.array.size == b->data.array.size &&
7864 (7868 (
7865 a.data.array.sentinel == b.data.array.sentinel ||7869 a->data.array.sentinel == b->data.array.sentinel ||
7866 (a.data.array.sentinel != nullptr && b.data.array.sentinel != nullptr &&7870 (a->data.array.sentinel != nullptr && b->data.array.sentinel != nullptr &&
7867 const_values_equal(a.data.array.codegen, a.data.array.sentinel, b.data.array.sentinel))7871 const_values_equal(a->data.array.codegen, a->data.array.sentinel, b->data.array.sentinel))
7868 );7872 );
7869 case ZigTypeIdInt:7873 case ZigTypeIdInt:
7870 return a.data.integer.is_signed == b.data.integer.is_signed &&7874 return a->data.integer.is_signed == b->data.integer.is_signed &&
7871 a.data.integer.bit_count == b.data.integer.bit_count;7875 a->data.integer.bit_count == b->data.integer.bit_count;
7872 case ZigTypeIdVector:7876 case ZigTypeIdVector:
7873 return a.data.vector.elem_type == b.data.vector.elem_type &&7877 return a->data.vector.elem_type == b->data.vector.elem_type &&
7874 a.data.vector.len == b.data.vector.len;7878 a->data.vector.len == b->data.vector.len;
7875 }7879 }
7876 zig_unreachable();7880 zig_unreachable();
7877}7881}
78787882
7879uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) {7883uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey const *x) {
7880 switch (x.id) {7884 switch (x->id) {
7881 case ZigLLVMFnIdCtz:7885 case ZigLLVMFnIdCtz:
7882 return (uint32_t)(x.data.ctz.bit_count) * (uint32_t)810453934;7886 return (uint32_t)(x->data.ctz.bit_count) * (uint32_t)810453934;
7883 case ZigLLVMFnIdClz:7887 case ZigLLVMFnIdClz:
7884 return (uint32_t)(x.data.clz.bit_count) * (uint32_t)2428952817;7888 return (uint32_t)(x->data.clz.bit_count) * (uint32_t)2428952817;
7885 case ZigLLVMFnIdPopCount:7889 case ZigLLVMFnIdPopCount:
7886 return (uint32_t)(x.data.clz.bit_count) * (uint32_t)101195049;7890 return (uint32_t)(x->data.clz.bit_count) * (uint32_t)101195049;
7887 case ZigLLVMFnIdFloatOp:7891 case ZigLLVMFnIdFloatOp:
7888 return (uint32_t)(x.data.floating.bit_count) * ((uint32_t)x.id + 1025) +7892 return (uint32_t)(x->data.floating.bit_count) * ((uint32_t)x->id + 1025) +
7889 (uint32_t)(x.data.floating.vector_len) * (((uint32_t)x.id << 5) + 1025) +7893 (uint32_t)(x->data.floating.vector_len) * (((uint32_t)x->id << 5) + 1025) +
7890 (uint32_t)(x.data.floating.op) * (uint32_t)43789879;7894 (uint32_t)(x->data.floating.op) * (uint32_t)43789879;
7891 case ZigLLVMFnIdFMA:7895 case ZigLLVMFnIdFMA:
7892 return (uint32_t)(x.data.floating.bit_count) * ((uint32_t)x.id + 1025) +7896 return (uint32_t)(x->data.floating.bit_count) * ((uint32_t)x->id + 1025) +
7893 (uint32_t)(x.data.floating.vector_len) * (((uint32_t)x.id << 5) + 1025);7897 (uint32_t)(x->data.floating.vector_len) * (((uint32_t)x->id << 5) + 1025);
7894 case ZigLLVMFnIdBswap:7898 case ZigLLVMFnIdBswap:
7895 return (uint32_t)(x.data.bswap.bit_count) * ((uint32_t)3661994335) +7899 return (uint32_t)(x->data.bswap.bit_count) * ((uint32_t)3661994335) +
7896 (uint32_t)(x.data.bswap.vector_len) * (((uint32_t)x.id << 5) + 1025);7900 (uint32_t)(x->data.bswap.vector_len) * (((uint32_t)x->id << 5) + 1025);
7897 case ZigLLVMFnIdBitReverse:7901 case ZigLLVMFnIdBitReverse:
7898 return (uint32_t)(x.data.bit_reverse.bit_count) * (uint32_t)2621398431;7902 return (uint32_t)(x->data.bit_reverse.bit_count) * (uint32_t)2621398431;
7899 case ZigLLVMFnIdOverflowArithmetic:7903 case ZigLLVMFnIdOverflowArithmetic:
7900 return ((uint32_t)(x.data.overflow_arithmetic.bit_count) * 87135777) +7904 return ((uint32_t)(x->data.overflow_arithmetic.bit_count) * 87135777) +
7901 ((uint32_t)(x.data.overflow_arithmetic.add_sub_mul) * 31640542) +7905 ((uint32_t)(x->data.overflow_arithmetic.add_sub_mul) * 31640542) +
7902 ((uint32_t)(x.data.overflow_arithmetic.is_signed) ? 1062315172 : 314955820) +7906 ((uint32_t)(x->data.overflow_arithmetic.is_signed) ? 1062315172 : 314955820) +
7903 x.data.overflow_arithmetic.vector_len * 1435156945;7907 x->data.overflow_arithmetic.vector_len * 1435156945;
7904 }7908 }
7905 zig_unreachable();7909 zig_unreachable();
7906}7910}
79077911
7908bool zig_llvm_fn_key_eql(ZigLLVMFnKey a, ZigLLVMFnKey b) {7912bool zig_llvm_fn_key_eql(ZigLLVMFnKey const *a, ZigLLVMFnKey const *b) {
7909 if (a.id != b.id)7913 if (a->id != b->id)
7910 return false;7914 return false;
7911 switch (a.id) {7915 switch (a->id) {
7912 case ZigLLVMFnIdCtz:7916 case ZigLLVMFnIdCtz:
7913 return a.data.ctz.bit_count == b.data.ctz.bit_count;7917 return a->data.ctz.bit_count == b->data.ctz.bit_count;
7914 case ZigLLVMFnIdClz:7918 case ZigLLVMFnIdClz:
7915 return a.data.clz.bit_count == b.data.clz.bit_count;7919 return a->data.clz.bit_count == b->data.clz.bit_count;
7916 case ZigLLVMFnIdPopCount:7920 case ZigLLVMFnIdPopCount:
7917 return a.data.pop_count.bit_count == b.data.pop_count.bit_count;7921 return a->data.pop_count.bit_count == b->data.pop_count.bit_count;
7918 case ZigLLVMFnIdBswap:7922 case ZigLLVMFnIdBswap:
7919 return a.data.bswap.bit_count == b.data.bswap.bit_count &&7923 return a->data.bswap.bit_count == b->data.bswap.bit_count &&
7920 a.data.bswap.vector_len == b.data.bswap.vector_len;7924 a->data.bswap.vector_len == b->data.bswap.vector_len;
7921 case ZigLLVMFnIdBitReverse:7925 case ZigLLVMFnIdBitReverse:
7922 return a.data.bit_reverse.bit_count == b.data.bit_reverse.bit_count;7926 return a->data.bit_reverse.bit_count == b->data.bit_reverse.bit_count;
7923 case ZigLLVMFnIdFloatOp:7927 case ZigLLVMFnIdFloatOp:
7924 return a.data.floating.bit_count == b.data.floating.bit_count &&7928 return a->data.floating.bit_count == b->data.floating.bit_count &&
7925 a.data.floating.vector_len == b.data.floating.vector_len &&7929 a->data.floating.vector_len == b->data.floating.vector_len &&
7926 a.data.floating.op == b.data.floating.op;7930 a->data.floating.op == b->data.floating.op;
7927 case ZigLLVMFnIdFMA:7931 case ZigLLVMFnIdFMA:
7928 return a.data.floating.bit_count == b.data.floating.bit_count &&7932 return a->data.floating.bit_count == b->data.floating.bit_count &&
7929 a.data.floating.vector_len == b.data.floating.vector_len;7933 a->data.floating.vector_len == b->data.floating.vector_len;
7930 case ZigLLVMFnIdOverflowArithmetic:7934 case ZigLLVMFnIdOverflowArithmetic:
7931 return (a.data.overflow_arithmetic.bit_count == b.data.overflow_arithmetic.bit_count) &&7935 return (a->data.overflow_arithmetic.bit_count == b->data.overflow_arithmetic.bit_count) &&
7932 (a.data.overflow_arithmetic.add_sub_mul == b.data.overflow_arithmetic.add_sub_mul) &&7936 (a->data.overflow_arithmetic.add_sub_mul == b->data.overflow_arithmetic.add_sub_mul) &&
7933 (a.data.overflow_arithmetic.is_signed == b.data.overflow_arithmetic.is_signed) &&7937 (a->data.overflow_arithmetic.is_signed == b->data.overflow_arithmetic.is_signed) &&
7934 (a.data.overflow_arithmetic.vector_len == b.data.overflow_arithmetic.vector_len);7938 (a->data.overflow_arithmetic.vector_len == b->data.overflow_arithmetic.vector_len);
7935 }7939 }
7936 zig_unreachable();7940 zig_unreachable();
7937}7941}
src/stage1/bigint.cpp+5-5
...@@ -1730,16 +1730,16 @@ Cmp bigint_cmp_zero(const BigInt *op) {...@@ -1730,16 +1730,16 @@ Cmp bigint_cmp_zero(const BigInt *op) {
1730 return op->is_negative ? CmpLT : CmpGT;1730 return op->is_negative ? CmpLT : CmpGT;
1731}1731}
17321732
1733uint32_t bigint_hash(BigInt x) {1733uint32_t bigint_hash(BigInt const *x) {
1734 if (x.digit_count == 0) {1734 if (x->digit_count == 0) {
1735 return 0;1735 return 0;
1736 } else {1736 } else {
1737 return bigint_ptr(&x)[0];1737 return bigint_ptr(x)[0];
1738 }1738 }
1739}1739}
17401740
1741bool bigint_eql(BigInt a, BigInt b) {1741bool bigint_eql(BigInt const *a, BigInt const *b) {
1742 return bigint_cmp(&a, &b) == CmpEQ;1742 return bigint_cmp(a, b) == CmpEQ;
1743}1743}
17441744
1745void bigint_incr(BigInt *x) {1745void bigint_incr(BigInt *x) {
src/stage1/bigint.hpp+2-2
...@@ -100,7 +100,7 @@ void bigint_decr(BigInt *value);...@@ -100,7 +100,7 @@ void bigint_decr(BigInt *value);
100100
101bool mul_u64_overflow(uint64_t op1, uint64_t op2, uint64_t *result);101bool mul_u64_overflow(uint64_t op1, uint64_t op2, uint64_t *result);
102102
103uint32_t bigint_hash(BigInt x);103uint32_t bigint_hash(BigInt const *x);
104bool bigint_eql(BigInt a, BigInt b);104bool bigint_eql(BigInt const *a, BigInt const *b);
105105
106#endif106#endif
src/stage1/hash_map.hpp+38-12
...@@ -12,7 +12,33 @@...@@ -12,7 +12,33 @@
1212
13#include <stdint.h>13#include <stdint.h>
1414
15template<typename K, typename V, uint32_t (*HashFunction)(K key), bool (*EqualFn)(K a, K b)>15template<typename K>
16struct MakePointer {
17 typedef K const *Type;
18 static Type convert(K const &val) {
19 return &val;
20 }
21};
22
23template<typename K>
24struct MakePointer<K*> {
25 typedef K *Type;
26 static Type convert(K * const &val) {
27 return val;
28 }
29};
30
31template<typename K>
32struct MakePointer<K const *> {
33 typedef K const *Type;
34 static Type convert(K const * const &val) {
35 return val;
36 }
37};
38
39template<typename K, typename V,
40 uint32_t (*HashFunction)(typename MakePointer<K>::Type key),
41 bool (*EqualFn)(typename MakePointer<K>::Type a, typename MakePointer<K>::Type b)>
16class HashMap {42class HashMap {
17public:43public:
18 void init(int capacity) {44 void init(int capacity) {
...@@ -51,7 +77,7 @@ public:...@@ -51,7 +77,7 @@ public:
5177
52 if (_index_bytes == nullptr) {78 if (_index_bytes == nullptr) {
53 if (_entries.length < 16) {79 if (_entries.length < 16) {
54 _entries.append({HashFunction(key), 0, key, value});80 _entries.append({HashFunction(MakePointer<K>::convert(key)), 0, key, value});
55 return;81 return;
56 } else {82 } else {
57 _indexes_len = 32;83 _indexes_len = 32;
...@@ -131,9 +157,9 @@ public:...@@ -131,9 +157,9 @@ public:
131 bool maybe_remove(const K &key) {157 bool maybe_remove(const K &key) {
132 _modification_count += 1;158 _modification_count += 1;
133 if (_index_bytes == nullptr) {159 if (_index_bytes == nullptr) {
134 uint32_t hash = HashFunction(key);160 uint32_t hash = HashFunction(MakePointer<K>::convert(key));
135 for (size_t i = 0; i < _entries.length; i += 1) {161 for (size_t i = 0; i < _entries.length; i += 1) {
136 if (_entries.items[i].hash == hash && EqualFn(_entries.items[i].key, key)) {162 if (_entries.items[i].hash == hash && EqualFn(MakePointer<K>::convert(_entries.items[i].key), MakePointer<K>::convert(key))) {
137 _entries.swap_remove(i);163 _entries.swap_remove(i);
138 return true;164 return true;
139 }165 }
...@@ -223,7 +249,7 @@ private:...@@ -223,7 +249,7 @@ private:
223249
224 template <typename I>250 template <typename I>
225 void internal_put(const K &key, const V &value, I *indexes) {251 void internal_put(const K &key, const V &value, I *indexes) {
226 uint32_t hash = HashFunction(key);252 uint32_t hash = HashFunction(MakePointer<K>::convert(key));
227 uint32_t distance_from_start_index = 0;253 uint32_t distance_from_start_index = 0;
228 size_t start_index = hash_to_index(hash);254 size_t start_index = hash_to_index(hash);
229 for (size_t roll_over = 0; roll_over < _indexes_len;255 for (size_t roll_over = 0; roll_over < _indexes_len;
...@@ -241,7 +267,7 @@ private:...@@ -241,7 +267,7 @@ private:
241 // This pointer survives the following append because we call267 // This pointer survives the following append because we call
242 // _entries.ensure_capacity before internal_put.268 // _entries.ensure_capacity before internal_put.
243 Entry *entry = &_entries.items[index_data - 1];269 Entry *entry = &_entries.items[index_data - 1];
244 if (entry->hash == hash && EqualFn(entry->key, key)) {270 if (entry->hash == hash && EqualFn(MakePointer<K>::convert(entry->key), MakePointer<K>::convert(key))) {
245 *entry = {hash, distance_from_start_index, key, value};271 *entry = {hash, distance_from_start_index, key, value};
246 if (distance_from_start_index > _max_distance_from_start_index)272 if (distance_from_start_index > _max_distance_from_start_index)
247 _max_distance_from_start_index = distance_from_start_index;273 _max_distance_from_start_index = distance_from_start_index;
...@@ -322,9 +348,9 @@ private:...@@ -322,9 +348,9 @@ private:
322348
323 Entry *internal_get(const K &key) const {349 Entry *internal_get(const K &key) const {
324 if (_index_bytes == nullptr) {350 if (_index_bytes == nullptr) {
325 uint32_t hash = HashFunction(key);351 uint32_t hash = HashFunction(MakePointer<K>::convert(key));
326 for (size_t i = 0; i < _entries.length; i += 1) {352 for (size_t i = 0; i < _entries.length; i += 1) {
327 if (_entries.items[i].hash == hash && EqualFn(_entries.items[i].key, key)) {353 if (_entries.items[i].hash == hash && EqualFn(MakePointer<K>::convert(_entries.items[i].key), MakePointer<K>::convert(key))) {
328 return &_entries.items[i];354 return &_entries.items[i];
329 }355 }
330 }356 }
...@@ -340,7 +366,7 @@ private:...@@ -340,7 +366,7 @@ private:
340366
341 template <typename I>367 template <typename I>
342 Entry *internal_get2(const K &key, I *indexes) const {368 Entry *internal_get2(const K &key, I *indexes) const {
343 uint32_t hash = HashFunction(key);369 uint32_t hash = HashFunction(MakePointer<K>::convert(key));
344 size_t start_index = hash_to_index(hash);370 size_t start_index = hash_to_index(hash);
345 for (size_t roll_over = 0; roll_over <= _max_distance_from_start_index; roll_over += 1) {371 for (size_t roll_over = 0; roll_over <= _max_distance_from_start_index; roll_over += 1) {
346 size_t index_index = (start_index + roll_over) % _indexes_len;372 size_t index_index = (start_index + roll_over) % _indexes_len;
...@@ -349,7 +375,7 @@ private:...@@ -349,7 +375,7 @@ private:
349 return nullptr;375 return nullptr;
350376
351 Entry *entry = &_entries.items[index_data - 1];377 Entry *entry = &_entries.items[index_data - 1];
352 if (entry->hash == hash && EqualFn(entry->key, key))378 if (entry->hash == hash && EqualFn(MakePointer<K>::convert(entry->key), MakePointer<K>::convert(key)))
353 return entry;379 return entry;
354 }380 }
355 return nullptr;381 return nullptr;
...@@ -361,7 +387,7 @@ private:...@@ -361,7 +387,7 @@ private:
361387
362 template <typename I>388 template <typename I>
363 bool internal_remove(const K &key, I *indexes) {389 bool internal_remove(const K &key, I *indexes) {
364 uint32_t hash = HashFunction(key);390 uint32_t hash = HashFunction(MakePointer<K>::convert(key));
365 size_t start_index = hash_to_index(hash);391 size_t start_index = hash_to_index(hash);
366 for (size_t roll_over = 0; roll_over <= _max_distance_from_start_index; roll_over += 1) {392 for (size_t roll_over = 0; roll_over <= _max_distance_from_start_index; roll_over += 1) {
367 size_t index_index = (start_index + roll_over) % _indexes_len;393 size_t index_index = (start_index + roll_over) % _indexes_len;
...@@ -371,7 +397,7 @@ private:...@@ -371,7 +397,7 @@ private:
371397
372 size_t index = index_data - 1;398 size_t index = index_data - 1;
373 Entry *entry = &_entries.items[index];399 Entry *entry = &_entries.items[index];
374 if (entry->hash != hash || !EqualFn(entry->key, key))400 if (entry->hash != hash || !EqualFn(MakePointer<K>::convert(entry->key), MakePointer<K>::convert(key)))
375 continue;401 continue;
376402
377 size_t prev_index = index_index;403 size_t prev_index = index_index;