From 35cea0b28d7d1479830489ba65bdf8f499834120 Mon Sep 17 00:00:00 2001 From: vanaigr Date: Wed, 18 Dec 2024 12:10:50 -0600 Subject: [PATCH] refactor: cleanup --- src/nvim/drawline.c | 11 +++-------- src/nvim/lua/treesitter.c | 27 +++++++++++++-------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 4e7cb7578d..4baa0317d9 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1483,16 +1483,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s } // Call it here since we need to invalidate the line pointer anyway. - bool added_decor = false; - decor_providers_invoke_line(wp, lnum - 1, &added_decor); - has_decor |= added_decor; + decor_providers_invoke_line(wp, lnum - 1, &has_decor); decor_provider_end_col = invoke_range_next(wp, lnum, col, rem_vcols + 1, &has_decor); line = ml_get_buf(wp->w_buffer, lnum); ptr = line + col; } - if (has_decor) { extra_check = true; } @@ -3039,18 +3036,16 @@ static int invoke_range_next(win_T *wp, int lnum, colnr_T begin_col, colnr_T col int const line_len = ml_get_buf_len(wp->w_buffer, lnum); col_off = MAX(col_off, 1); - bool added_decor = false; colnr_T new_col; if (col_off <= line_len - begin_col) { int end_col = begin_col + col_off; end_col += mb_off_next(line, line + end_col); - decor_providers_invoke_range(wp, lnum - 1, begin_col, lnum - 1, end_col, &added_decor); + decor_providers_invoke_range(wp, lnum - 1, begin_col, lnum - 1, end_col, has_decor); new_col = end_col; } else { - decor_providers_invoke_range(wp, lnum - 1, begin_col, lnum, 0, &added_decor); + decor_providers_invoke_range(wp, lnum - 1, begin_col, lnum, 0, has_decor); new_col = INT_MAX; } - *has_decor |= added_decor; return new_col; } diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index 14eb825485..798e09c714 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -1291,23 +1291,22 @@ static inline bool set_uint32(lua_State *L, int idx, char const *name, uint32_t FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL { lua_getfield(L, idx, name); - - if (!lua_isnil(L, -1)) { - int64_t value = lua_tointeger(L, -1); - if (value < 0U) { - *res = 0U; - return true; - } else if (value > UINT32_MAX) { - *res = UINT32_MAX; - return true; - } else { - *res = (uint32_t)value; - return true; - } + if (lua_isnil(L, -1)) { + lua_pop(L, 1); + return false; } + + int64_t value = lua_tointeger(L, -1); lua_pop(L, 1); - return false; + if (value < 0U) { + *res = 0U; + } else if (value > UINT32_MAX) { + *res = UINT32_MAX; + } else { + *res = (uint32_t)value; + } + return true; } int tslua_push_querycursor(lua_State *L)