Add inline attributes to few hot funcs

This commit is contained in:
Alex Orlenko 2021-09-20 12:38:08 +01:00
parent 3597e34ffb
commit ee1c8a1a3d
No known key found for this signature in database
GPG Key ID: 4C150C250863B96D
5 changed files with 57 additions and 0 deletions

View File

@ -20,24 +20,28 @@ use crate::userdata::{AnyUserData, UserData};
use crate::value::{FromLua, Nil, ToLua, Value}; use crate::value::{FromLua, Nil, ToLua, Value};
impl<'lua> ToLua<'lua> for Value<'lua> { impl<'lua> ToLua<'lua> for Value<'lua> {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(self) Ok(self)
} }
} }
impl<'lua> FromLua<'lua> for Value<'lua> { impl<'lua> FromLua<'lua> for Value<'lua> {
#[inline]
fn from_lua(lua_value: Value<'lua>, _: &'lua Lua) -> Result<Self> { fn from_lua(lua_value: Value<'lua>, _: &'lua Lua) -> Result<Self> {
Ok(lua_value) Ok(lua_value)
} }
} }
impl<'lua> ToLua<'lua> for String<'lua> { impl<'lua> ToLua<'lua> for String<'lua> {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::String(self)) Ok(Value::String(self))
} }
} }
impl<'lua> FromLua<'lua> for String<'lua> { impl<'lua> FromLua<'lua> for String<'lua> {
#[inline]
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<String<'lua>> { fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<String<'lua>> {
let ty = value.type_name(); let ty = value.type_name();
lua.coerce_string(value)? lua.coerce_string(value)?
@ -50,12 +54,14 @@ impl<'lua> FromLua<'lua> for String<'lua> {
} }
impl<'lua> ToLua<'lua> for Table<'lua> { impl<'lua> ToLua<'lua> for Table<'lua> {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Table(self)) Ok(Value::Table(self))
} }
} }
impl<'lua> FromLua<'lua> for Table<'lua> { impl<'lua> FromLua<'lua> for Table<'lua> {
#[inline]
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Table<'lua>> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Table<'lua>> {
match value { match value {
Value::Table(table) => Ok(table), Value::Table(table) => Ok(table),
@ -69,12 +75,14 @@ impl<'lua> FromLua<'lua> for Table<'lua> {
} }
impl<'lua> ToLua<'lua> for Function<'lua> { impl<'lua> ToLua<'lua> for Function<'lua> {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Function(self)) Ok(Value::Function(self))
} }
} }
impl<'lua> FromLua<'lua> for Function<'lua> { impl<'lua> FromLua<'lua> for Function<'lua> {
#[inline]
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Function<'lua>> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Function<'lua>> {
match value { match value {
Value::Function(table) => Ok(table), Value::Function(table) => Ok(table),
@ -88,12 +96,14 @@ impl<'lua> FromLua<'lua> for Function<'lua> {
} }
impl<'lua> ToLua<'lua> for Thread<'lua> { impl<'lua> ToLua<'lua> for Thread<'lua> {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Thread(self)) Ok(Value::Thread(self))
} }
} }
impl<'lua> FromLua<'lua> for Thread<'lua> { impl<'lua> FromLua<'lua> for Thread<'lua> {
#[inline]
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Thread<'lua>> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Thread<'lua>> {
match value { match value {
Value::Thread(t) => Ok(t), Value::Thread(t) => Ok(t),
@ -107,12 +117,14 @@ impl<'lua> FromLua<'lua> for Thread<'lua> {
} }
impl<'lua> ToLua<'lua> for AnyUserData<'lua> { impl<'lua> ToLua<'lua> for AnyUserData<'lua> {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::UserData(self)) Ok(Value::UserData(self))
} }
} }
impl<'lua> FromLua<'lua> for AnyUserData<'lua> { impl<'lua> FromLua<'lua> for AnyUserData<'lua> {
#[inline]
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<AnyUserData<'lua>> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<AnyUserData<'lua>> {
match value { match value {
Value::UserData(ud) => Ok(ud), Value::UserData(ud) => Ok(ud),
@ -126,12 +138,14 @@ impl<'lua> FromLua<'lua> for AnyUserData<'lua> {
} }
impl<'lua, T: 'static + MaybeSend + UserData> ToLua<'lua> for T { impl<'lua, T: 'static + MaybeSend + UserData> ToLua<'lua> for T {
#[inline]
fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::UserData(lua.create_userdata(self)?)) Ok(Value::UserData(lua.create_userdata(self)?))
} }
} }
impl<'lua, T: 'static + UserData + Clone> FromLua<'lua> for T { impl<'lua, T: 'static + UserData + Clone> FromLua<'lua> for T {
#[inline]
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<T> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<T> {
match value { match value {
Value::UserData(ud) => Ok(ud.borrow::<T>()?.clone()), Value::UserData(ud) => Ok(ud.borrow::<T>()?.clone()),
@ -145,12 +159,14 @@ impl<'lua, T: 'static + UserData + Clone> FromLua<'lua> for T {
} }
impl<'lua> ToLua<'lua> for Error { impl<'lua> ToLua<'lua> for Error {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Error(self)) Ok(Value::Error(self))
} }
} }
impl<'lua> FromLua<'lua> for Error { impl<'lua> FromLua<'lua> for Error {
#[inline]
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Error> { fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Error> {
match value { match value {
Value::Error(err) => Ok(err), Value::Error(err) => Ok(err),
@ -164,12 +180,14 @@ impl<'lua> FromLua<'lua> for Error {
} }
impl<'lua> ToLua<'lua> for bool { impl<'lua> ToLua<'lua> for bool {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::Boolean(self)) Ok(Value::Boolean(self))
} }
} }
impl<'lua> FromLua<'lua> for bool { impl<'lua> FromLua<'lua> for bool {
#[inline]
fn from_lua(v: Value<'lua>, _: &'lua Lua) -> Result<Self> { fn from_lua(v: Value<'lua>, _: &'lua Lua) -> Result<Self> {
match v { match v {
Value::Nil => Ok(false), Value::Nil => Ok(false),
@ -180,12 +198,14 @@ impl<'lua> FromLua<'lua> for bool {
} }
impl<'lua> ToLua<'lua> for LightUserData { impl<'lua> ToLua<'lua> for LightUserData {
#[inline]
fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, _: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::LightUserData(self)) Ok(Value::LightUserData(self))
} }
} }
impl<'lua> FromLua<'lua> for LightUserData { impl<'lua> FromLua<'lua> for LightUserData {
#[inline]
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Self> { fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<Self> {
match value { match value {
Value::LightUserData(ud) => Ok(ud), Value::LightUserData(ud) => Ok(ud),
@ -199,12 +219,14 @@ impl<'lua> FromLua<'lua> for LightUserData {
} }
impl<'lua> ToLua<'lua> for StdString { impl<'lua> ToLua<'lua> for StdString {
#[inline]
fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::String(lua.create_string(&self)?)) Ok(Value::String(lua.create_string(&self)?))
} }
} }
impl<'lua> FromLua<'lua> for StdString { impl<'lua> FromLua<'lua> for StdString {
#[inline]
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self> { fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self> {
let ty = value.type_name(); let ty = value.type_name();
Ok(lua Ok(lua
@ -220,6 +242,7 @@ impl<'lua> FromLua<'lua> for StdString {
} }
impl<'lua> ToLua<'lua> for &str { impl<'lua> ToLua<'lua> for &str {
#[inline]
fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
Ok(Value::String(lua.create_string(self)?)) Ok(Value::String(lua.create_string(self)?))
} }
@ -595,6 +618,7 @@ impl<'lua, T: Ord + FromLua<'lua>> FromLua<'lua> for BTreeSet<T> {
} }
impl<'lua, T: ToLua<'lua>> ToLua<'lua> for Option<T> { impl<'lua, T: ToLua<'lua>> ToLua<'lua> for Option<T> {
#[inline]
fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> { fn to_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
match self { match self {
Some(val) => val.to_lua(lua), Some(val) => val.to_lua(lua),
@ -604,6 +628,7 @@ impl<'lua, T: ToLua<'lua>> ToLua<'lua> for Option<T> {
} }
impl<'lua, T: FromLua<'lua>> FromLua<'lua> for Option<T> { impl<'lua, T: FromLua<'lua>> FromLua<'lua> for Option<T> {
#[inline]
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self> { fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self> {
match value { match value {
Nil => Ok(None), Nil => Ok(None),

View File

@ -341,6 +341,7 @@ where
} }
#[cfg(feature = "async")] #[cfg(feature = "async")]
#[inline(always)]
fn is_poll_pending(val: &MultiValue) -> bool { fn is_poll_pending(val: &MultiValue) -> bool {
match val.iter().enumerate().last() { match val.iter().enumerate().last() {
Some((1, Value::LightUserData(ud))) => { Some((1, Value::LightUserData(ud))) => {

View File

@ -597,11 +597,13 @@ pub trait UserData: Sized {
pub(crate) struct UserDataCell<T>(RefCell<UserDataWrapped<T>>); pub(crate) struct UserDataCell<T>(RefCell<UserDataWrapped<T>>);
impl<T> UserDataCell<T> { impl<T> UserDataCell<T> {
#[inline]
pub(crate) fn new(data: T) -> Self { pub(crate) fn new(data: T) -> Self {
UserDataCell(RefCell::new(UserDataWrapped::new(data))) UserDataCell(RefCell::new(UserDataWrapped::new(data)))
} }
#[cfg(feature = "serialize")] #[cfg(feature = "serialize")]
#[inline]
pub(crate) fn new_ser(data: T) -> Self pub(crate) fn new_ser(data: T) -> Self
where where
T: 'static + Serialize, T: 'static + Serialize,
@ -610,6 +612,7 @@ impl<T> UserDataCell<T> {
} }
// Immutably borrows the wrapped value. // Immutably borrows the wrapped value.
#[inline]
fn try_borrow(&self) -> Result<Ref<T>> { fn try_borrow(&self) -> Result<Ref<T>> {
self.0 self.0
.try_borrow() .try_borrow()
@ -618,6 +621,7 @@ impl<T> UserDataCell<T> {
} }
// Mutably borrows the wrapped value. // Mutably borrows the wrapped value.
#[inline]
fn try_borrow_mut(&self) -> Result<RefMut<T>> { fn try_borrow_mut(&self) -> Result<RefMut<T>> {
self.0 self.0
.try_borrow_mut() .try_borrow_mut()
@ -633,11 +637,13 @@ pub(crate) enum UserDataWrapped<T> {
} }
impl<T> UserDataWrapped<T> { impl<T> UserDataWrapped<T> {
#[inline]
fn new(data: T) -> Self { fn new(data: T) -> Self {
UserDataWrapped::Default(data) UserDataWrapped::Default(data)
} }
#[cfg(feature = "serialize")] #[cfg(feature = "serialize")]
#[inline]
fn new_ser(data: T) -> Self fn new_ser(data: T) -> Self
where where
T: 'static + Serialize, T: 'static + Serialize,
@ -659,6 +665,7 @@ impl<T> Drop for UserDataWrapped<T> {
impl<T> Deref for UserDataWrapped<T> { impl<T> Deref for UserDataWrapped<T> {
type Target = T; type Target = T;
#[inline]
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
match self { match self {
Self::Default(data) => data, Self::Default(data) => data,
@ -669,6 +676,7 @@ impl<T> Deref for UserDataWrapped<T> {
} }
impl<T> DerefMut for UserDataWrapped<T> { impl<T> DerefMut for UserDataWrapped<T> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
match self { match self {
Self::Default(data) => data, Self::Default(data) => data,
@ -726,6 +734,7 @@ impl<'lua> AnyUserData<'lua> {
/// ///
/// Returns a `UserDataBorrowError` if the userdata is already mutably borrowed. Returns a /// Returns a `UserDataBorrowError` if the userdata is already mutably borrowed. Returns a
/// `UserDataTypeMismatch` if the userdata is not of type `T`. /// `UserDataTypeMismatch` if the userdata is not of type `T`.
#[inline]
pub fn borrow<T: 'static + UserData>(&self) -> Result<Ref<T>> { pub fn borrow<T: 'static + UserData>(&self) -> Result<Ref<T>> {
self.inspect(|cell| cell.try_borrow()) self.inspect(|cell| cell.try_borrow())
} }
@ -736,6 +745,7 @@ impl<'lua> AnyUserData<'lua> {
/// ///
/// Returns a `UserDataBorrowMutError` if the userdata cannot be mutably borrowed. /// Returns a `UserDataBorrowMutError` if the userdata cannot be mutably borrowed.
/// Returns a `UserDataTypeMismatch` if the userdata is not of type `T`. /// Returns a `UserDataTypeMismatch` if the userdata is not of type `T`.
#[inline]
pub fn borrow_mut<T: 'static + UserData>(&self) -> Result<RefMut<T>> { pub fn borrow_mut<T: 'static + UserData>(&self) -> Result<RefMut<T>> {
self.inspect(|cell| cell.try_borrow_mut()) self.inspect(|cell| cell.try_borrow_mut())
} }

View File

@ -19,6 +19,7 @@ static METATABLE_CACHE: Lazy<Mutex<HashMap<TypeId, u8>>> = Lazy::new(|| {
// Checks that Lua has enough free stack space for future stack operations. On failure, this will // Checks that Lua has enough free stack space for future stack operations. On failure, this will
// panic with an internal error message. // panic with an internal error message.
#[inline]
pub unsafe fn assert_stack(state: *mut ffi::lua_State, amount: c_int) { pub unsafe fn assert_stack(state: *mut ffi::lua_State, amount: c_int) {
// TODO: This should only be triggered when there is a logic error in `mlua`. In the future, // TODO: This should only be triggered when there is a logic error in `mlua`. In the future,
// when there is a way to be confident about stack safety and test it, this could be enabled // when there is a way to be confident about stack safety and test it, this could be enabled
@ -30,6 +31,7 @@ pub unsafe fn assert_stack(state: *mut ffi::lua_State, amount: c_int) {
} }
// Checks that Lua has enough free stack space and returns `Error::StackError` on failure. // Checks that Lua has enough free stack space and returns `Error::StackError` on failure.
#[inline]
pub unsafe fn check_stack(state: *mut ffi::lua_State, amount: c_int) -> Result<()> { pub unsafe fn check_stack(state: *mut ffi::lua_State, amount: c_int) -> Result<()> {
if ffi::lua_checkstack(state, amount) == 0 { if ffi::lua_checkstack(state, amount) == 0 {
Err(Error::StackError) Err(Error::StackError)
@ -48,6 +50,7 @@ impl StackGuard {
// Creates a StackGuard instance with record of the stack size, and on Drop will check the // Creates a StackGuard instance with record of the stack size, and on Drop will check the
// stack size and drop any extra elements. If the stack size at the end is *smaller* than at // stack size and drop any extra elements. If the stack size at the end is *smaller* than at
// the beginning, this is considered a fatal logic error and will result in a panic. // the beginning, this is considered a fatal logic error and will result in a panic.
#[inline]
pub unsafe fn new(state: *mut ffi::lua_State) -> StackGuard { pub unsafe fn new(state: *mut ffi::lua_State) -> StackGuard {
StackGuard { StackGuard {
state, state,
@ -57,6 +60,7 @@ impl StackGuard {
} }
// Similar to `new`, but checks and keeps `extra` elements from top of the stack on Drop. // Similar to `new`, but checks and keeps `extra` elements from top of the stack on Drop.
#[inline]
pub unsafe fn new_extra(state: *mut ffi::lua_State, extra: c_int) -> StackGuard { pub unsafe fn new_extra(state: *mut ffi::lua_State, extra: c_int) -> StackGuard {
StackGuard { StackGuard {
state, state,
@ -211,6 +215,7 @@ pub unsafe fn pop_error(state: *mut ffi::lua_State, err_code: c_int) -> Error {
} }
// Uses 3 stack spaces // Uses 3 stack spaces
#[inline]
pub unsafe fn push_string<S: AsRef<[u8]> + ?Sized>( pub unsafe fn push_string<S: AsRef<[u8]> + ?Sized>(
state: *mut ffi::lua_State, state: *mut ffi::lua_State,
s: &S, s: &S,
@ -222,6 +227,7 @@ pub unsafe fn push_string<S: AsRef<[u8]> + ?Sized>(
} }
// Uses 3 stack spaces // Uses 3 stack spaces
#[inline]
pub unsafe fn push_table(state: *mut ffi::lua_State, narr: c_int, nrec: c_int) -> Result<()> { pub unsafe fn push_table(state: *mut ffi::lua_State, narr: c_int, nrec: c_int) -> Result<()> {
protect_lua(state, 0, 1, |state| ffi::lua_createtable(state, narr, nrec)) protect_lua(state, 0, 1, |state| ffi::lua_createtable(state, narr, nrec))
} }
@ -241,6 +247,7 @@ where
} }
// Internally uses 3 stack spaces, does not call checkstack. // Internally uses 3 stack spaces, does not call checkstack.
#[inline]
pub unsafe fn push_userdata<T>(state: *mut ffi::lua_State, t: T) -> Result<()> { pub unsafe fn push_userdata<T>(state: *mut ffi::lua_State, t: T) -> Result<()> {
let ud = protect_lua(state, 0, 1, |state| { let ud = protect_lua(state, 0, 1, |state| {
ffi::lua_newuserdata(state, mem::size_of::<T>()) as *mut T ffi::lua_newuserdata(state, mem::size_of::<T>()) as *mut T
@ -249,6 +256,7 @@ pub unsafe fn push_userdata<T>(state: *mut ffi::lua_State, t: T) -> Result<()> {
Ok(()) Ok(())
} }
#[inline]
pub unsafe fn get_userdata<T>(state: *mut ffi::lua_State, index: c_int) -> *mut T { pub unsafe fn get_userdata<T>(state: *mut ffi::lua_State, index: c_int) -> *mut T {
let ud = ffi::lua_touserdata(state, index) as *mut T; let ud = ffi::lua_touserdata(state, index) as *mut T;
mlua_debug_assert!(!ud.is_null(), "userdata pointer is null"); mlua_debug_assert!(!ud.is_null(), "userdata pointer is null");

View File

@ -157,18 +157,21 @@ pub struct MultiValue<'lua>(Vec<Value<'lua>>);
impl<'lua> MultiValue<'lua> { impl<'lua> MultiValue<'lua> {
/// Creates an empty `MultiValue` containing no values. /// Creates an empty `MultiValue` containing no values.
#[inline]
pub fn new() -> MultiValue<'lua> { pub fn new() -> MultiValue<'lua> {
MultiValue(Vec::new()) MultiValue(Vec::new())
} }
} }
impl<'lua> Default for MultiValue<'lua> { impl<'lua> Default for MultiValue<'lua> {
#[inline]
fn default() -> MultiValue<'lua> { fn default() -> MultiValue<'lua> {
MultiValue::new() MultiValue::new()
} }
} }
impl<'lua> FromIterator<Value<'lua>> for MultiValue<'lua> { impl<'lua> FromIterator<Value<'lua>> for MultiValue<'lua> {
#[inline]
fn from_iter<I: IntoIterator<Item = Value<'lua>>>(iter: I) -> Self { fn from_iter<I: IntoIterator<Item = Value<'lua>>>(iter: I) -> Self {
MultiValue::from_vec(Vec::from_iter(iter)) MultiValue::from_vec(Vec::from_iter(iter))
} }
@ -178,6 +181,7 @@ impl<'lua> IntoIterator for MultiValue<'lua> {
type Item = Value<'lua>; type Item = Value<'lua>;
type IntoIter = iter::Rev<vec::IntoIter<Value<'lua>>>; type IntoIter = iter::Rev<vec::IntoIter<Value<'lua>>>;
#[inline]
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.0.into_iter().rev() self.0.into_iter().rev()
} }
@ -187,43 +191,52 @@ impl<'a, 'lua> IntoIterator for &'a MultiValue<'lua> {
type Item = &'a Value<'lua>; type Item = &'a Value<'lua>;
type IntoIter = iter::Rev<slice::Iter<'a, Value<'lua>>>; type IntoIter = iter::Rev<slice::Iter<'a, Value<'lua>>>;
#[inline]
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
(&self.0).iter().rev() (&self.0).iter().rev()
} }
} }
impl<'lua> MultiValue<'lua> { impl<'lua> MultiValue<'lua> {
#[inline]
pub fn from_vec(mut v: Vec<Value<'lua>>) -> MultiValue<'lua> { pub fn from_vec(mut v: Vec<Value<'lua>>) -> MultiValue<'lua> {
v.reverse(); v.reverse();
MultiValue(v) MultiValue(v)
} }
#[inline]
pub fn into_vec(self) -> Vec<Value<'lua>> { pub fn into_vec(self) -> Vec<Value<'lua>> {
let mut v = self.0; let mut v = self.0;
v.reverse(); v.reverse();
v v
} }
#[inline]
pub(crate) fn reserve(&mut self, size: usize) { pub(crate) fn reserve(&mut self, size: usize) {
self.0.reserve(size); self.0.reserve(size);
} }
#[inline]
pub(crate) fn push_front(&mut self, value: Value<'lua>) { pub(crate) fn push_front(&mut self, value: Value<'lua>) {
self.0.push(value); self.0.push(value);
} }
#[inline]
pub(crate) fn pop_front(&mut self) -> Option<Value<'lua>> { pub(crate) fn pop_front(&mut self) -> Option<Value<'lua>> {
self.0.pop() self.0.pop()
} }
#[inline]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.0.len() self.0.len()
} }
#[inline]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.0.len() == 0 self.0.len() == 0
} }
#[inline]
pub fn iter(&self) -> iter::Rev<slice::Iter<Value<'lua>>> { pub fn iter(&self) -> iter::Rev<slice::Iter<Value<'lua>>> {
self.0.iter().rev() self.0.iter().rev()
} }