mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 06:18:16 +00:00
refactor: replace unnecessary helper functions in optionstr.c
Replaces unnecessary helper functions in `optionstr.c` such as `get_option_flags()`, `get_option_fullname()`, `set_option_flag()`, `is_global_option()`, etc. with a single `get_option()` helper function that allows direct access to the `options` array. Also refactors `f_exists()` to use `get_varp_scope` instead of using `get_option_tv`. This opens up the path for removing `getoptions_T` altogether later down the line since the hidden option logic is no longer needed.
This commit is contained in:
@@ -1938,9 +1938,14 @@ static void f_exists(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
xfree(exp);
|
||||
}
|
||||
} else if (*p == '&' || *p == '+') { // Option.
|
||||
n = (get_option_tv(&p, NULL, true) == OK);
|
||||
if (*skipwhite(p) != NUL) {
|
||||
n = false; // Trailing garbage.
|
||||
bool working = (*p == '+'); // whether option needs to be working
|
||||
int opt_flags;
|
||||
|
||||
if (find_option_end(&p, &opt_flags) != NULL) {
|
||||
int opt_idx = findoption(p);
|
||||
n = (opt_idx >= 0 && (!working || get_varp_scope(get_option(opt_idx), opt_flags) != NULL));
|
||||
} else {
|
||||
n = false;
|
||||
}
|
||||
} else if (*p == '*') { // Internal or user defined function.
|
||||
n = function_exists(p + 1, false);
|
||||
|
Reference in New Issue
Block a user