mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 13:13:18 +00:00 
			
		
		
		
	Merge #8298
8298: Stop using an upgradeable read lock in interning r=jonas-schievink a=jonas-schievink 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. bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
		
						commit
						8e3e13f3a4
					
				@ -25,7 +25,7 @@ impl<T: Internable> Interned<T> {
 | 
				
			|||||||
        let storage = T::storage().get();
 | 
					        let storage = T::storage().get();
 | 
				
			||||||
        let shard_idx = storage.determine_map(&obj);
 | 
					        let shard_idx = storage.determine_map(&obj);
 | 
				
			||||||
        let shard = &storage.shards()[shard_idx];
 | 
					        let shard = &storage.shards()[shard_idx];
 | 
				
			||||||
        let shard = shard.upgradeable_read();
 | 
					        let mut shard = shard.write();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Atomically,
 | 
					        // Atomically,
 | 
				
			||||||
        // - check if `obj` is already in the map
 | 
					        // - check if `obj` is already in the map
 | 
				
			||||||
@ -43,10 +43,7 @@ impl<T: Internable> Interned<T> {
 | 
				
			|||||||
        let arc = Arc::new(obj);
 | 
					        let arc = Arc::new(obj);
 | 
				
			||||||
        let arc2 = arc.clone();
 | 
					        let arc2 = arc.clone();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            let mut shard = shard.upgrade();
 | 
					 | 
				
			||||||
        shard.insert(arc2, SharedValue::new(()));
 | 
					        shard.insert(arc2, SharedValue::new(()));
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Self { arc }
 | 
					        Self { arc }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user