mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Convert some static wcstring_list_t to C arrays
Saves some allocations at startup.
This commit is contained in:
parent
e6d09dc4fe
commit
5735703261
4 changed files with 11 additions and 10 deletions
|
@ -496,8 +496,8 @@ void builtin_init() {
|
|||
bool builtin_exists(const wcstring &cmd) { return static_cast<bool>(builtin_lookup(cmd)); }
|
||||
|
||||
/// Is the command a keyword we need to special-case the handling of `-h` and `--help`.
|
||||
static const wcstring_list_t help_builtins({L"for", L"while", L"function", L"if", L"end", L"switch",
|
||||
L"case"});
|
||||
static const wchar_t *const help_builtins[] = {L"for", L"while", L"function", L"if",
|
||||
L"end", L"switch", L"case"};
|
||||
static bool cmd_needs_help(const wchar_t *cmd) { return contains(help_builtins, cmd); }
|
||||
|
||||
/// Execute a builtin command
|
||||
|
|
|
@ -68,7 +68,7 @@ static const struct woption long_options[] = {
|
|||
_(L"%ls: Universal variable '%ls' is shadowed by the global variable of the same name.\n")
|
||||
|
||||
// Test if the specified variable should be subject to path validation.
|
||||
static const wcstring_list_t path_variables({L"PATH", L"CDPATH"});
|
||||
static const wchar_t *const path_variables[] = {L"PATH", L"CDPATH"};
|
||||
static int is_path_variable(const wchar_t *env) { return contains(path_variables, env); }
|
||||
|
||||
static int parse_cmd_opts(set_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
|
|
|
@ -424,7 +424,7 @@ bool term_supports_setting_title() { return can_set_term_title; }
|
|||
/// One situation in which this breaks down is with screen, since screen supports setting the
|
||||
/// terminal title if the underlying terminal does so, but will print garbage on terminals that
|
||||
/// don't. Since we can't see the underlying terminal below screen there is no way to fix this.
|
||||
static const wcstring_list_t title_terms({L"xterm", L"screen", L"tmux", L"nxterm", L"rxvt"});
|
||||
static const wchar_t *const title_terms[] = {L"xterm", L"screen", L"tmux", L"nxterm", L"rxvt"};
|
||||
static bool does_term_support_setting_title() {
|
||||
const auto term_var = env_get(L"TERM");
|
||||
if (term_var.missing_or_empty()) return false;
|
||||
|
|
|
@ -11,18 +11,19 @@ bool parser_keywords_skip_arguments(const wcstring &cmd) {
|
|||
return cmd == L"else" || cmd == L"begin";
|
||||
}
|
||||
|
||||
static const wcstring_list_t subcommand_keywords({L"command", L"builtin", L"while", L"exec", L"if",
|
||||
L"and", L"or", L"not"});
|
||||
static const wchar_t *const subcommand_keywords[] = {L"command", L"builtin", L"while", L"exec",
|
||||
L"if", L"and", L"or", L"not"};
|
||||
bool parser_keywords_is_subcommand(const wcstring &cmd) {
|
||||
return parser_keywords_skip_arguments(cmd) || contains(subcommand_keywords, cmd);
|
||||
}
|
||||
|
||||
static const wcstring_list_t block_keywords({L"for", L"while", L"if", L"function", L"switch",
|
||||
L"begin"});
|
||||
static const wchar_t *const block_keywords[] = {L"for", L"while", L"if",
|
||||
L"function", L"switch", L"begin"};
|
||||
bool parser_keywords_is_block(const wcstring &word) { return contains(block_keywords, word); }
|
||||
|
||||
static const wcstring_list_t reserved_keywords({L"end", L"case", L"else", L"return", L"continue",
|
||||
L"break", L"argparse", L"read", L"set", L"status", L"test", L"["});
|
||||
static const wchar_t *const reserved_keywords[] = {L"end", L"case", L"else", L"return",
|
||||
L"continue", L"break", L"argparse", L"read",
|
||||
L"set", L"status", L"test", L"["};
|
||||
bool parser_keywords_is_reserved(const wcstring &word) {
|
||||
return parser_keywords_is_block(word) || parser_keywords_is_subcommand(word) ||
|
||||
contains(reserved_keywords, word);
|
||||
|
|
Loading…
Reference in a new issue