slightly faster, less obnoxious scope drop

This commit is contained in:
kyren 2018-02-07 16:51:24 -05:00
parent 98ee4e9492
commit b9d9bea28a
1 changed files with 6 additions and 4 deletions

View File

@ -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);
}
}