From 8e0cc99215b9ad8afadd960cbb6206280add6c32 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 29 Sep 2015 18:19:07 -0400 Subject: [PATCH] Seems like there's no more optimizations that can be made to `sol/function`... Only other thing to optimize is `usertype`, maybe. --- sol/function.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sol/function.hpp b/sol/function.hpp index ea972bb4..06e12072 100644 --- a/sol/function.hpp +++ b/sol/function.hpp @@ -225,10 +225,12 @@ struct pusher> { // idx n + 1: is the object's void pointer // We don't need to store the size, because the other side is templated // with the same member function pointer type - Decay memfxptr(std::forward(fx)); + typedef Decay dFx; + typedef Unqualified uFx; + dFx memfxptr(std::forward(fx)); auto userptr = sol::detail::get_ptr(obj); void* userobjdata = static_cast(userptr); - lua_CFunction freefunc = &static_member_function, Fx>::call; + lua_CFunction freefunc = &static_member_function, uFx>::call; int upvalues = stack::detail::push_as_upvalues(L, memfxptr); upvalues += stack::push(L, userobjdata); @@ -252,8 +254,9 @@ struct pusher> { base_function* target = luafunc.release(); void* userdata = reinterpret_cast(target); lua_CFunction freefunc = &base_function::call; - - if(luaL_newmetatable(L, metatablename) == 1) { + + int metapushed = luaL_newmetatable(L, metatablename); + if(metapushed == 1) { lua_pushstring(L, "__gc"); stack::push(L, &base_function::gc); lua_settable(L, -3);