mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +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:
@@ -1617,7 +1617,7 @@ failed:
|
||||
save_file_ff(curbuf);
|
||||
// If editing a new file: set 'fenc' for the current buffer.
|
||||
// Also for ":read ++edit file".
|
||||
set_string_option_direct("fenc", -1, fenc, OPT_FREE | OPT_LOCAL, 0);
|
||||
set_string_option_direct(kOptFileencoding, fenc, OPT_FREE | OPT_LOCAL, 0);
|
||||
}
|
||||
if (fenc_alloced) {
|
||||
xfree(fenc);
|
||||
@@ -1965,7 +1965,7 @@ void set_forced_fenc(exarg_T *eap)
|
||||
}
|
||||
|
||||
char *fenc = enc_canonize(eap->cmd + eap->force_enc);
|
||||
set_string_option_direct("fenc", -1, fenc, OPT_FREE|OPT_LOCAL, 0);
|
||||
set_string_option_direct(kOptFileencoding, fenc, OPT_FREE|OPT_LOCAL, 0);
|
||||
xfree(fenc);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user