Skip to content

Commit

Permalink
Change lock scope when decoding Allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Jul 7, 2024
1 parent 11dd90f commit 1486ae4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ impl<'s> AllocDecodingSession<'s> {

// Check the decoding state to see if it's already decoded or if we should
// decode it here.
let mut entry = self.state.decoding_state[idx].lock();
let alloc_id = {
let mut entry = self.state.decoding_state[idx].lock();

match *entry {
State::Done(alloc_id) => {
return alloc_id;
Expand Down Expand Up @@ -317,9 +316,7 @@ impl<'s> AllocDecodingSession<'s> {
}
});

self.state.decoding_state[idx].with_lock(|entry| {
*entry = State::Done(alloc_id);
});
*entry = State::Done(alloc_id);

alloc_id
}
Expand Down

0 comments on commit 1486ae4

Please sign in to comment.