@@ -193,6 +193,29 @@ _Py_hashtable_get_entry_generic(_Py_hashtable_t *ht, const void *key)
193
193
}
194
194
195
195
196
+ // Specialized for:
197
+ // hash_func == _Py_hashtable_hash_ptr
198
+ // compare_func == _Py_hashtable_compare_direct
199
+ static _Py_hashtable_entry_t *
200
+ _Py_hashtable_get_entry_ptr (_Py_hashtable_t * ht , const void * key )
201
+ {
202
+ Py_uhash_t key_hash = _Py_hashtable_hash_ptr (key );
203
+ size_t index = key_hash & (ht -> num_buckets - 1 );
204
+ _Py_hashtable_entry_t * entry = entry = TABLE_HEAD (ht , index );
205
+ while (1 ) {
206
+ if (entry == NULL ) {
207
+ return NULL ;
208
+ }
209
+ // Compare directly keys (ignore entry->key_hash)
210
+ if (entry -> key == key ) {
211
+ break ;
212
+ }
213
+ entry = ENTRY_NEXT (entry );
214
+ }
215
+ return entry ;
216
+ }
217
+
218
+
196
219
void *
197
220
_Py_hashtable_steal (_Py_hashtable_t * ht , const void * key )
198
221
{
@@ -275,30 +298,6 @@ _Py_hashtable_get(_Py_hashtable_t *ht, const void *key)
275
298
}
276
299
277
300
278
- // Specialized for:
279
- // hash_func == _Py_hashtable_hash_ptr
280
- // compare_func == _Py_hashtable_compare_direct
281
- _Py_hashtable_entry_t *
282
- _Py_hashtable_get_entry_ptr (_Py_hashtable_t * ht , const void * key )
283
- {
284
- Py_uhash_t key_hash = _Py_hashtable_hash_ptr (key );
285
- size_t index = key_hash & (ht -> num_buckets - 1 );
286
- _Py_hashtable_entry_t * entry = entry = TABLE_HEAD (ht , index );
287
- while (1 ) {
288
- if (entry == NULL ) {
289
- return NULL ;
290
- }
291
- if (entry -> key_hash == key_hash ) {
292
- if (entry -> key == key ) {
293
- break ;
294
- }
295
- }
296
- entry = ENTRY_NEXT (entry );
297
- }
298
- return entry ;
299
- }
300
-
301
-
302
301
int
303
302
_Py_hashtable_foreach (_Py_hashtable_t * ht ,
304
303
_Py_hashtable_foreach_func func ,
0 commit comments