diff options
author | kyren <kerriganw@gmail.com> | 2018-02-07 16:51:24 -0500 |
---|---|---|
committer | kyren <kerriganw@gmail.com> | 2018-02-07 16:51:24 -0500 |
commit | b9d9bea28a86ff8097bb52f0398143692aedb5b9 (patch) | |
tree | 8e413b1b632e7a518677c36d39cd7e23def2996a /src | |
parent | 98ee4e9492b626268b7170d713686da6a258cbb9 (diff) | |
download | mlua-b9d9bea28a86ff8097bb52f0398143692aedb5b9.zip |
slightly faster, less obnoxious scope drop
Diffstat (limited to 'src')
-rw-r--r-- | src/lua.rs | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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); } } |