summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkyren <kerriganw@gmail.com>2018-02-07 16:51:24 -0500
committerkyren <kerriganw@gmail.com>2018-02-07 16:51:24 -0500
commitb9d9bea28a86ff8097bb52f0398143692aedb5b9 (patch)
tree8e413b1b632e7a518677c36d39cd7e23def2996a /src
parent98ee4e9492b626268b7170d713686da6a258cbb9 (diff)
downloadmlua-b9d9bea28a86ff8097bb52f0398143692aedb5b9.zip
slightly faster, less obnoxious scope drop
Diffstat (limited to 'src')
-rw-r--r--src/lua.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lua.rs b/src/lua.rs
index 588a0b2..a0320e6 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -1101,10 +1101,12 @@ impl<'lua> Drop for Scope<'lua> {
// can be sure that all of the userdata in Lua is actually invalidated.
let state = self.lua.state;
- let mut drops = Vec::new();
- for mut destructor in self.destructors.get_mut().drain(..) {
- drops.push(destructor(state));
- }
+ let to_drop = self.destructors
+ .get_mut()
+ .drain(..)
+ .map(|mut destructor| destructor(state))
+ .collect::<Vec<_>>();
+ drop(to_drop);
}
}