Skip to content

Commit 99762ee

Browse files
bors[bot]Shnatsel
andauthored
Merge #442
442: Do not perform superfluous bounds checks on dropping crossbeam-epoch::Bag r=jeehoonkang a=Shnatsel Addresses [this comment](#414 (comment)) that I didn't get a chance to act upon before merging #414. This way bounds checks should be performed only once. However, this does not measurably impact benchmarks. Co-authored-by: Sergey "Shnatsel" Davidoff <[email protected]>
2 parents d2ab7a5 + ebb6b5f commit 99762ee

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crossbeam-epoch/src/internal.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ impl Default for Bag {
133133
impl Drop for Bag {
134134
fn drop(&mut self) {
135135
// Call all deferred functions.
136-
for i in 0..self.len {
136+
for deferred in &mut self.deferreds[..self.len] {
137137
let no_op = Deferred::new(no_op_func);
138-
let deferred = mem::replace(&mut self.deferreds[i], no_op);
139-
deferred.call();
138+
let owned_deferred = mem::replace(deferred, no_op);
139+
owned_deferred.call();
140140
}
141141
}
142142
}

0 commit comments

Comments
 (0)