Seems like there's no more optimizations that can be made to sol/function...

Only other thing to optimize is `usertype`, maybe.
This commit is contained in:
ThePhD 2015-09-29 18:19:07 -04:00
parent 895030c69e
commit 8e0cc99215

View File

@ -225,10 +225,12 @@ struct pusher<function_sig_t<Sigs...>> {
// idx n + 1: is the object's void pointer // idx n + 1: is the object's void pointer
// We don't need to store the size, because the other side is templated // We don't need to store the size, because the other side is templated
// with the same member function pointer type // with the same member function pointer type
Decay<Fx> memfxptr(std::forward<Fx>(fx)); typedef Decay<Fx> dFx;
typedef Unqualified<Fx> uFx;
dFx memfxptr(std::forward<Fx>(fx));
auto userptr = sol::detail::get_ptr(obj); auto userptr = sol::detail::get_ptr(obj);
void* userobjdata = static_cast<void*>(userptr); void* userobjdata = static_cast<void*>(userptr);
lua_CFunction freefunc = &static_member_function<Decay<decltype(*userptr)>, Fx>::call; lua_CFunction freefunc = &static_member_function<Decay<decltype(*userptr)>, uFx>::call;
int upvalues = stack::detail::push_as_upvalues(L, memfxptr); int upvalues = stack::detail::push_as_upvalues(L, memfxptr);
upvalues += stack::push(L, userobjdata); upvalues += stack::push(L, userobjdata);
@ -253,7 +255,8 @@ struct pusher<function_sig_t<Sigs...>> {
void* userdata = reinterpret_cast<void*>(target); void* userdata = reinterpret_cast<void*>(target);
lua_CFunction freefunc = &base_function::call; 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"); lua_pushstring(L, "__gc");
stack::push(L, &base_function::gc); stack::push(L, &base_function::gc);
lua_settable(L, -3); lua_settable(L, -3);