slightly faster, less obnoxious scope drop
This commit is contained in:
parent
98ee4e9492
commit
b9d9bea28a
10
src/lua.rs
10
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.
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue