From 7e85064ac77ea43e84d88eb910b0adb6f07d5d12 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Tue, 21 May 2024 10:23:25 -0600 Subject: remove some ui pointer chasing There only exists a single Ui so there is no need to force a pointer redirection for accessing it. The Ui member was moved down in vis-core.h to punt around an issue with the way lua checks for existing objects. It may show up again as I flatten more structs. --- vis-lua.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'vis-lua.c') diff --git a/vis-lua.c b/vis-lua.c index 3b5f784..6bd8a08 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -1399,7 +1399,7 @@ static int vis_index(lua_State *L) { } if (strcmp(key, "registers") == 0) { - obj_ref_new(L, vis->ui, VIS_LUA_TYPE_REGISTERS); + obj_ref_new(L, &vis->ui, VIS_LUA_TYPE_REGISTERS); return 1; } @@ -1415,7 +1415,7 @@ static int vis_index(lua_State *L) { } if (strcmp(key, "ui") == 0) { - obj_ref_new(L, vis->ui, VIS_LUA_TYPE_UI); + obj_ref_new(L, &vis->ui, VIS_LUA_TYPE_UI); return 1; } } @@ -1429,8 +1429,7 @@ static int vis_options_assign(Vis *vis, lua_State *L, const char *key, int next) } else if (strcmp(key, "changecolors") == 0) { vis->change_colors = lua_toboolean(L, next); } else if (strcmp(key, "escdelay") == 0) { - TermKey *tk = vis->ui->termkey; - termkey_set_waittime(tk, luaL_checkint(L, next)); + termkey_set_waittime(vis->ui.termkey, luaL_checkint(L, next)); } else if (strcmp(key, "ignorecase") == 0 || strcmp(key, "ic") == 0) { vis->ignorecase = lua_toboolean(L, next); } else if (strcmp(key, "loadmethod") == 0) { @@ -1570,8 +1569,7 @@ static int vis_options_index(lua_State *L) { lua_pushboolean(L, vis->change_colors); return 1; } else if (strcmp(key, "escdelay") == 0) { - TermKey *tk = vis->ui->termkey; - lua_pushunsigned(L, termkey_get_waittime(tk)); + lua_pushunsigned(L, termkey_get_waittime(vis->ui.termkey)); return 1; } else if (strcmp(key, "ignorecase") == 0 || strcmp(key, "ic") == 0) { lua_pushboolean(L, vis->ignorecase); @@ -3612,7 +3610,7 @@ static void vis_lua_ui_draw(Vis *vis) { bool vis_event_emit(Vis *vis, enum VisEvents id, ...) { if (!vis->initialized) { vis->initialized = true; - ui_init(vis->ui, vis); + ui_init(&vis->ui, vis); vis_lua_init(vis); } -- cgit v1.2.3