From 7ad6a90ea2e75388d42b5b223d9273119994037e Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 10 Apr 2016 01:11:09 -0700 Subject: [PATCH] Change parser_token_types from wcstring to const wchar_t * Reduces allocations and startup time --- src/fish_indent.cpp | 2 +- src/parse_constants.h | 2 +- src/parse_tree.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index 0e31f28e7..d2e239438 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -104,7 +104,7 @@ static void dump_node(indent_t node_indent, const parse_node_t &node, const wcst } fwprintf(stderr, L"{off %4d, len %4d, indent %2u, %ls} [%ls|%ls|%ls]\n", node.source_start, node.source_length, node_indent, - parser_token_types[node.type].c_str(), prevc_str, source.substr(node.source_start, + parser_token_types[node.type], prevc_str, source.substr(node.source_start, node.source_length).c_str(), nextc_str); } diff --git a/src/parse_constants.h b/src/parse_constants.h index afc88c6c2..03dffd285 100644 --- a/src/parse_constants.h +++ b/src/parse_constants.h @@ -83,7 +83,7 @@ enum parse_token_type_t LAST_PARSE_TOKEN_TYPE = parse_token_type_end } __packed; // Array of strings corresponding to the enums above instantiated in parse_tree.cpp. -extern wcstring parser_token_types[]; +extern const wchar_t * const parser_token_types[]; /* These must be maintained in sorted order (except for none, which isn't a keyword). This enables us to do binary search. */ enum parse_keyword_t diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index cdaec9ef0..ca6e310b9 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -17,7 +17,7 @@ #include // This array provides strings for each symbol in enum parse_token_type_t in parse_constants.h. -wcstring parser_token_types[] = { +const wchar_t * const parser_token_types[] = { L"token_type_invalid", L"symbol_job_list", L"symbol_job",