From 8f08b1efbd096850c04c2e8e2890d993bd4d9f95 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Sun, 17 Dec 2023 05:23:33 +0600 Subject: refactor(options): use hashy for finding options (#26573) Problem: `findoption()` searches through the options[] table linearly for option names, even though hashy can be used to generate a compile-time hash table for it. Solution: Use hashy to generate a compile time hash table for finding options. This also allows handling option aliases, so we don't need separate options[] table entries for things like 'viminfo'. --- src/nvim/api/deprecated.c | 4 ++-- src/nvim/api/options.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c index 371361c5a1..27af581ef4 100644 --- a/src/nvim/api/deprecated.c +++ b/src/nvim/api/deprecated.c @@ -643,7 +643,7 @@ static Object get_option_from(void *from, OptReqScope req_scope, String name, Er return (Object)OBJECT_INIT; }); - OptVal value = get_option_value_strict(findoption(name.data), req_scope, from, err); + OptVal value = get_option_value_strict(find_option(name.data), req_scope, from, err); if (ERROR_SET(err)) { return (Object)OBJECT_INIT; } @@ -669,7 +669,7 @@ static void set_option_to(uint64_t channel_id, void *to, OptReqScope req_scope, return; }); - OptIndex opt_idx = findoption(name.data); + OptIndex opt_idx = find_option(name.data); VALIDATE_S(opt_idx != kOptInvalid, "option name", name.data, { return; }); diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index 54a2fbf385..a3ea7d9d47 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -79,7 +79,7 @@ static int validate_option_value_args(Dict(option) *opts, char *name, OptIndex * return FAIL; }); - *opt_idxp = findoption(name); + *opt_idxp = find_option(name); int flags = get_option_attrs(*opt_idxp); if (flags == 0) { // hidden or unknown option -- cgit