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. // can be sure that all of the userdata in Lua is actually invalidated.
let state = self.lua.state; let state = self.lua.state;
let mut drops = Vec::new(); let to_drop = self.destructors
for mut destructor in self.destructors.get_mut().drain(..) { .get_mut()
drops.push(destructor(state)); .drain(..)
} .map(|mut destructor| destructor(state))
.collect::<Vec<_>>();
drop(to_drop);
} }
} }