From 269f907f2f853bc7535103880998a11016d61360 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Tue, 9 Jun 2020 15:16:31 -0700 Subject: [PATCH] Use inline ivar initialization in parse_node_t --- src/parse_tree.h | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/parse_tree.h b/src/parse_tree.h index 5eb89e5cc..61082d227 100644 --- a/src/parse_tree.h +++ b/src/parse_tree.h @@ -93,19 +93,19 @@ typedef uint8_t parse_node_tag_t; class parse_node_t { public: // Start in the source code. - source_offset_t source_start; + source_offset_t source_start{SOURCE_OFFSET_INVALID}; // Length of our range in the source code. - source_offset_t source_length; + source_offset_t source_length{0}; // Parent - node_offset_t parent; + node_offset_t parent{NODE_OFFSET_INVALID}; // Children - node_offset_t child_start; + node_offset_t child_start{0}; // Number of children. - uint8_t child_count; + uint8_t child_count{0}; // Type of the node. enum parse_token_type_t type; // Keyword associated with node. - enum parse_keyword_t keyword; + enum parse_keyword_t keyword { parse_keyword_t::none }; // Node flags. parse_node_flags_t flags : 4; // This is used to store e.g. the statement decoration. @@ -114,16 +114,7 @@ class parse_node_t { wcstring describe() const; // Constructor - explicit parse_node_t(parse_token_type_t ty) - : source_start(SOURCE_OFFSET_INVALID), - source_length(0), - parent(NODE_OFFSET_INVALID), - child_start(0), - child_count(0), - type(ty), - keyword(parse_keyword_t::none), - flags(0), - tag(0) {} + explicit parse_node_t(parse_token_type_t ty) : type(ty), flags(0), tag(0) {} node_offset_t child_offset(node_offset_t which) const { PARSE_ASSERT(which < child_count);