From ebb6b5fe6d7423a97a7762fa5fde7cb2d801fd39 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Sun, 27 Oct 2019 10:58:49 +0100 Subject: [PATCH] Do not perform superfluous bounds checks on drop --- crossbeam-epoch/src/internal.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crossbeam-epoch/src/internal.rs b/crossbeam-epoch/src/internal.rs index d43e2b766..22038f30d 100644 --- a/crossbeam-epoch/src/internal.rs +++ b/crossbeam-epoch/src/internal.rs @@ -133,10 +133,10 @@ impl Default for Bag { impl Drop for Bag { fn drop(&mut self) { // Call all deferred functions. - for i in 0..self.len { + for deferred in &mut self.deferreds[..self.len] { let no_op = Deferred::new(no_op_func); - let deferred = mem::replace(&mut self.deferreds[i], no_op); - deferred.call(); + let owned_deferred = mem::replace(deferred, no_op); + owned_deferred.call(); } } }