mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +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:
@@ -905,7 +905,7 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear
|
||||
need_wait_return = false;
|
||||
}
|
||||
|
||||
set_string_option_direct("icm", -1, s->save_p_icm, OPT_FREE, SID_NONE);
|
||||
set_string_option_direct(kOptInccommand, s->save_p_icm, OPT_FREE, SID_NONE);
|
||||
State = s->save_State;
|
||||
if (cmdpreview != save_cmdpreview) {
|
||||
cmdpreview = save_cmdpreview; // restore preview state
|
||||
@@ -4326,7 +4326,7 @@ static int open_cmdwin(void)
|
||||
return Ctrl_C;
|
||||
}
|
||||
// Command-line buffer has bufhidden=wipe, unlike a true "scratch" buffer.
|
||||
set_option_value_give_err("bh", STATIC_CSTR_AS_OPTVAL("wipe"), OPT_LOCAL);
|
||||
set_option_value_give_err(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("wipe"), OPT_LOCAL);
|
||||
curbuf->b_p_ma = true;
|
||||
curwin->w_p_fen = false;
|
||||
curwin->w_p_rl = cmdmsg_rl;
|
||||
@@ -4344,7 +4344,7 @@ static int open_cmdwin(void)
|
||||
add_map("<Tab>", "<C-X><C-V>", MODE_INSERT, true);
|
||||
add_map("<Tab>", "a<C-X><C-V>", MODE_NORMAL, true);
|
||||
}
|
||||
set_option_value_give_err("ft", STATIC_CSTR_AS_OPTVAL("vim"), OPT_LOCAL);
|
||||
set_option_value_give_err(kOptFiletype, STATIC_CSTR_AS_OPTVAL("vim"), OPT_LOCAL);
|
||||
}
|
||||
curbuf->b_ro_locked--;
|
||||
|
||||
|
Reference in New Issue
Block a user