aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-02 19:46:37 +0100
committerJonas Schievink <[email protected]>2021-04-02 19:46:37 +0100
commite73d26fa62c61602e0bceb7d9cf7c661badee57b (patch)
tree8541571011ca81bcb2536374f43873fdc049295e /crates/hir_def/src
parent0129628a0f497834a544fa981078b43321c9020a (diff)
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.
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/intern.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/crates/hir_def/src/intern.rs b/crates/hir_def/src/intern.rs
index cc0b5d350..bc0307dbc 100644
--- a/crates/hir_def/src/intern.rs
+++ b/crates/hir_def/src/intern.rs
@@ -25,7 +25,7 @@ impl<T: Internable> Interned<T> {
25 let storage = T::storage().get(); 25 let storage = T::storage().get();
26 let shard_idx = storage.determine_map(&obj); 26 let shard_idx = storage.determine_map(&obj);
27 let shard = &storage.shards()[shard_idx]; 27 let shard = &storage.shards()[shard_idx];
28 let shard = shard.upgradeable_read(); 28 let mut shard = shard.write();
29 29
30 // Atomically, 30 // Atomically,
31 // - check if `obj` is already in the map 31 // - check if `obj` is already in the map
@@ -43,10 +43,7 @@ impl<T: Internable> Interned<T> {
43 let arc = Arc::new(obj); 43 let arc = Arc::new(obj);
44 let arc2 = arc.clone(); 44 let arc2 = arc.clone();
45 45
46 { 46 shard.insert(arc2, SharedValue::new(()));
47 let mut shard = shard.upgrade();
48 shard.insert(arc2, SharedValue::new(()));
49 }
50 47
51 Self { arc } 48 Self { arc }
52 } 49 }