mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
refactor(options): reduce findoption()
usage
Problem: Many places in the code use `findoption()` to access an option using its name, even if the option index is available. This is very slow because it requires looping through the options array over and over. Solution: Use option index instead of name wherever possible. Also introduce an `OptIndex` enum which contains the index for every option as enum constants, this eliminates the need to pass static option names as strings.
This commit is contained in:
@@ -1091,7 +1091,7 @@ void ex_retab(exarg_T *eap)
|
||||
colnr_T *old_vts_ary = curbuf->b_p_vts_array;
|
||||
|
||||
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) {
|
||||
set_string_option_direct("vts", -1, new_ts_str, OPT_FREE | OPT_LOCAL, 0);
|
||||
set_string_option_direct(kOptVartabstop, new_ts_str, OPT_FREE | OPT_LOCAL, 0);
|
||||
curbuf->b_p_vts_array = new_vts_array;
|
||||
xfree(old_vts_ary);
|
||||
} else {
|
||||
@@ -1115,7 +1115,7 @@ int get_expr_indent(void)
|
||||
colnr_T save_curswant;
|
||||
int save_set_curswant;
|
||||
int save_State;
|
||||
int use_sandbox = was_set_insecurely(curwin, "indentexpr", OPT_LOCAL);
|
||||
int use_sandbox = was_set_insecurely(curwin, kOptIndentexpr, OPT_LOCAL);
|
||||
const sctx_T save_sctx = current_sctx;
|
||||
|
||||
// Save and restore cursor position and curswant, in case it was changed
|
||||
|
Reference in New Issue
Block a user