More performance optimizations
This commit is contained in:
parent
440862de38
commit
1b74c89509
|
@ -364,7 +364,9 @@ macro_rules! lua_convert_int {
|
|||
impl<'lua> FromLua<'lua> for $x {
|
||||
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self> {
|
||||
let ty = value.type_name();
|
||||
(if let Some(i) = lua.coerce_integer(value.clone())? {
|
||||
(if let Value::Integer(i) = value {
|
||||
cast(i)
|
||||
} else if let Some(i) = lua.coerce_integer(value.clone())? {
|
||||
cast(i)
|
||||
} else {
|
||||
cast(lua.coerce_number(value)?.ok_or_else(|| {
|
||||
|
|
|
@ -2230,13 +2230,14 @@ impl Lua {
|
|||
args.push_front(lua.pop_value());
|
||||
}
|
||||
|
||||
let results = ((*upvalue).func)(&lua, args)?;
|
||||
let mut results = ((*upvalue).func)(&lua, args)?;
|
||||
let nresults = results.len() as c_int;
|
||||
|
||||
check_stack(state, nresults)?;
|
||||
for r in results {
|
||||
for r in results.drain_all() {
|
||||
lua.push_value(r)?;
|
||||
}
|
||||
lua.cache_multivalue(results);
|
||||
|
||||
Ok(nresults)
|
||||
})
|
||||
|
|
|
@ -53,7 +53,7 @@ pub enum Value<'lua> {
|
|||
pub use self::Value::Nil;
|
||||
|
||||
impl<'lua> Value<'lua> {
|
||||
pub fn type_name(&self) -> &'static str {
|
||||
pub const fn type_name(&self) -> &'static str {
|
||||
match *self {
|
||||
Value::Nil => "nil",
|
||||
Value::Boolean(_) => "boolean",
|
||||
|
|
Loading…
Reference in New Issue