mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
slightly faster, less obnoxious scope drop
This commit is contained in:
+6
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user