Skip to content

Commit e73d26f

Browse files
Stop using an upgradeable read lock in interning
Only one upgradeable read lock can be handed out at the same time, and we never acquire a non-upgradeable read lock, so this has no benefit over just using a write lock in the first place.
1 parent 0129628 commit e73d26f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

crates/hir_def/src/intern.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<T: Internable> Interned<T> {
2525
let storage = T::storage().get();
2626
let shard_idx = storage.determine_map(&obj);
2727
let shard = &storage.shards()[shard_idx];
28-
let shard = shard.upgradeable_read();
28+
let mut shard = shard.write();
2929

3030
// Atomically,
3131
// - check if `obj` is already in the map
@@ -43,10 +43,7 @@ impl<T: Internable> Interned<T> {
4343
let arc = Arc::new(obj);
4444
let arc2 = arc.clone();
4545

46-
{
47-
let mut shard = shard.upgrade();
48-
shard.insert(arc2, SharedValue::new(()));
49-
}
46+
shard.insert(arc2, SharedValue::new(()));
5047

5148
Self { arc }
5249
}

0 commit comments

Comments
 (0)