From 11a9054b1d09e53aaba642fbdf8b145d1a64c7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 17 Jul 2026 08:04:40 +0200 Subject: [PATCH] player/lua: pre-allocate tables of known size --- player/lua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/player/lua.c b/player/lua.c index 8ecdeac410..85aacbcd31 100644 --- a/player/lua.c +++ b/player/lua.c @@ -898,7 +898,7 @@ static void pushnode(lua_State *L, mpv_node *node) lua_pushboolean(L, node->u.flag); break; case MPV_FORMAT_NODE_ARRAY: - lua_newtable(L); // table + lua_createtable(L, node->u.list->num, 0); // table lua_getfield(L, LUA_REGISTRYINDEX, "ARRAY"); // table mt lua_setmetatable(L, -2); // table for (int n = 0; n < node->u.list->num; n++) { @@ -907,7 +907,7 @@ static void pushnode(lua_State *L, mpv_node *node) } break; case MPV_FORMAT_NODE_MAP: - lua_newtable(L); // table + lua_createtable(L, 0, node->u.list->num); // table lua_getfield(L, LUA_REGISTRYINDEX, "MAP"); // table mt lua_setmetatable(L, -2); // table for (int n = 0; n < node->u.list->num; n++) {