Skip to content

Commit 5f3042e

Browse files
committed
Refactor and speed up ActiveGuardDrop.
To fix a small perf regression from #153471.
1 parent d27207d commit 5f3042e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

compiler/rustc_query_impl/src/execution.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ where
164164
let mut this = ManuallyDrop::new(self);
165165

166166
// Drop everything without poisoning the query.
167-
this.drop_and_maybe_poison(/* poison */ false);
167+
this.drop_and_maybe_poison::<false>();
168168
}
169169

170-
fn drop_and_maybe_poison(&mut self, poison: bool) {
170+
fn drop_and_maybe_poison<const POISON: bool>(&mut self) {
171171
let status = {
172172
let mut shard = self.state.active.lock_shard_by_hash(self.key_hash);
173173
match shard.find_entry(self.key_hash, equivalent_key(self.key)) {
@@ -179,7 +179,7 @@ where
179179
}
180180
Ok(occupied) => {
181181
let ((key, status), vacant) = occupied.remove();
182-
if poison {
182+
if POISON {
183183
vacant.insert((key, ActiveKeyStatus::Poisoned));
184184
}
185185
status
@@ -203,7 +203,7 @@ where
203203
#[cold]
204204
fn drop(&mut self) {
205205
// Poison the query so jobs waiting on it panic.
206-
self.drop_and_maybe_poison(/* poison */ true);
206+
self.drop_and_maybe_poison::<true>();
207207
}
208208
}
209209

0 commit comments

Comments
 (0)