@@ -326,21 +326,38 @@ where
326
326
327
327
let current_job_id = qcx. current_query_job ( ) ;
328
328
329
- match state_lock. raw_entry_mut ( ) . from_key_hashed_nocheck ( key_hash, & key) {
330
- RawEntryMut :: Vacant ( entry) => {
329
+ match state_lock. raw_table_mut ( ) . find_or_find_insert_slot (
330
+ key_hash,
331
+ |( k, _) | * k == key,
332
+ |( k, _) | sharded:: make_hash ( k) ,
333
+ ) {
334
+ Err ( free_slot) => {
331
335
// Nothing has computed or is computing the query, so we start a new job and insert it in the
332
336
// state map.
333
337
let id = qcx. next_job_id ( ) ;
334
338
let job = QueryJob :: new ( id, span, current_job_id) ;
335
- entry. insert_hashed_nocheck ( key_hash, key, QueryResult :: Started ( job) ) ;
339
+
340
+ // SAFETY: The slot is still valid as there's
341
+ // been no mutation to the table since we hold the lock.
342
+ unsafe {
343
+ state_lock. raw_table_mut ( ) . insert_in_slot (
344
+ key_hash,
345
+ free_slot,
346
+ ( key, QueryResult :: Started ( job) ) ,
347
+ ) ;
348
+ }
336
349
337
350
// Drop the lock before we start executing the query
338
351
drop ( state_lock) ;
339
352
340
353
execute_job :: < _ , _ , INCR > ( query, qcx, state, key, key_hash, id, dep_node)
341
354
}
342
- RawEntryMut :: Occupied ( mut entry) => {
343
- match entry. get_mut ( ) {
355
+ Ok ( bucket) => {
356
+ // SAFETY: We know this bucket is still valid
357
+ // since we just got it from `find_or_find_insert_slot`.
358
+ let entry = unsafe { & mut bucket. as_mut ( ) . 1 } ;
359
+
360
+ match entry {
344
361
QueryResult :: Started ( job) => {
345
362
#[ cfg( parallel_compiler) ]
346
363
if sync:: is_dyn_thread_safe ( ) {
0 commit comments