experimental optimize canvas:set_data using ffi

This commit is contained in:
MihailRis
2025-03-08 18:04:10 +03:00
parent 6078a8802e
commit e48216da40
6 changed files with 61 additions and 13 deletions
+6 -2
View File
@@ -163,20 +163,23 @@ int lua::call(State* L, int argc, int nresults) {
int handler_pos = gettop(L) - argc;
pushcfunction(L, l_error_handler);
insert(L, handler_pos);
int top = gettop(L);
if (lua_pcall(L, argc, nresults, handler_pos)) {
std::string log = tostring(L, -1);
pop(L);
remove(L, handler_pos);
throw luaerror(log);
}
int added = gettop(L) - (top - argc - 1);
remove(L, handler_pos);
return nresults == -1 ? 1 : nresults;
return added;
}
int lua::call_nothrow(State* L, int argc, int nresults) {
int handler_pos = gettop(L) - argc;
pushcfunction(L, l_error_handler);
insert(L, handler_pos);
int top = gettop(L);
if (lua_pcall(L, argc, -1, handler_pos)) {
auto errorstr = tostring(L, -1);
if (errorstr) {
@@ -188,8 +191,9 @@ int lua::call_nothrow(State* L, int argc, int nresults) {
remove(L, handler_pos);
return 0;
}
int added = gettop(L) - (top - argc - 1);
remove(L, handler_pos);
return 1;
return added;
}
void lua::dump_stack(State* L) {