| 103 key.len = str == NULL ? 0 : strlen(str); |
103 key.len = str == NULL ? 0 : strlen(str); |
| 104 cx_hash_murmur(&key); |
104 cx_hash_murmur(&key); |
| 105 return key; |
105 return key; |
| 106 } |
106 } |
| 107 |
107 |
| |
108 CxHashKey cx_hash_key_ustr(unsigned const char *str) { |
| |
109 CxHashKey key; |
| |
110 key.data = str; |
| |
111 key.len = str == NULL ? 0 : strlen((const char*)str); |
| |
112 cx_hash_murmur(&key); |
| |
113 return key; |
| |
114 } |
| |
115 |
| |
116 CxHashKey cx_hash_key_cxstr(cxstring str) { |
| |
117 return cx_hash_key(str.ptr, str.length); |
| |
118 } |
| |
119 |
| |
120 CxHashKey cx_hash_key_mutstr(cxmutstr str) { |
| |
121 return cx_hash_key(str.ptr, str.length); |
| |
122 } |
| |
123 |
| 108 CxHashKey cx_hash_key_bytes( |
124 CxHashKey cx_hash_key_bytes( |
| 109 const unsigned char *bytes, |
125 const unsigned char *bytes, |
| 110 size_t len |
126 size_t len |
| 111 ) { |
127 ) { |
| 112 CxHashKey key; |
128 CxHashKey key; |
| 141 key.len = 0; |
157 key.len = 0; |
| 142 key.hash = cx_hash_u64(x); |
158 key.hash = cx_hash_u64(x); |
| 143 return key; |
159 return key; |
| 144 } |
160 } |
| 145 |
161 |
| 146 int cx_hash_key_cmp(const CxHashKey *left, const CxHashKey *right) { |
162 int cx_hash_key_cmp(const void *l, const void *r) { |
| |
163 const CxHashKey *left = l; |
| |
164 const CxHashKey *right = r; |
| 147 int d; |
165 int d; |
| 148 d = cx_vcmp_uint64(left->hash, right->hash); |
166 d = cx_vcmp_uint64(left->hash, right->hash); |
| 149 if (d != 0) return d; |
167 if (d != 0) return d; |
| 150 d = cx_vcmp_size(left->len, right->len); |
168 d = cx_vcmp_size(left->len, right->len); |
| 151 if (d != 0) return d; |
169 if (d != 0) return d; |