diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-01-22 09:24:34 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-01-22 09:24:34 +0100 |
commit | 14fde9162dfdcd497f17fa799abce1146263893f (patch) | |
tree | 06267af130595c36ed1aa6c83178cd68b10779a2 /gcc | |
parent | 1c402757ca18d91b8979b5ba634fc945dbb8b94b (diff) | |
download | gcc-14fde9162dfdcd497f17fa799abce1146263893f.zip gcc-14fde9162dfdcd497f17fa799abce1146263893f.tar.gz gcc-14fde9162dfdcd497f17fa799abce1146263893f.tar.bz2 |
c++: Improve cp_parser_objc_messsage_args compile time
On Tue, Jan 21, 2025 at 06:47:53PM +0100, Jakub Jelinek wrote:
> Indeed, I've just used what it was doing without thinking too much about it,
> sorry.
> addl_args = tree_cons (NULL_TREE, arg, addl_args);
> with addl_args = nreverse (addl_args); after the loop might be better,
> can test that incrementally. sel_args is handled the same and should have
> the same treatment.
Here is incremental patch to do that.
Verified also on the 2 va-meth*.mm testcases (one without CPP_EMBED, one
with) that -fdump-tree-gimple is the same before/after the patch.
2025-01-22 Jakub Jelinek <jakub@redhat.com>
* parser.cc (cp_parser_objc_message_args): Use tree_cons with
nreverse at the end for both sel_args and addl_args, instead of
chainon with build_tree_list second argument.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/parser.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index a9eddd1..e1fa7e5 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -36721,9 +36721,7 @@ cp_parser_objc_message_args (cp_parser* parser) cp_parser_require (parser, CPP_COLON, RT_COLON); arg = cp_parser_assignment_expression (parser); - sel_args - = chainon (sel_args, - build_tree_list (selector, arg)); + sel_args = tree_cons (selector, arg, sel_args); token = cp_lexer_peek_token (parser->lexer); } @@ -36738,14 +36736,12 @@ cp_parser_objc_message_args (cp_parser* parser) tree raw_data = cp_lexer_peek_token (parser->lexer)->u.value; cp_lexer_consume_token (parser->lexer); for (tree argument : raw_data_range (raw_data)) - addl_args = chainon (addl_args, - build_tree_list (NULL_TREE, argument)); + addl_args = tree_cons (NULL_TREE, argument, addl_args); } else { tree arg = cp_parser_assignment_expression (parser); - addl_args = chainon (addl_args, - build_tree_list (NULL_TREE, arg)); + addl_args = tree_cons (NULL_TREE, arg, addl_args); } token = cp_lexer_peek_token (parser->lexer); @@ -36757,7 +36753,7 @@ cp_parser_objc_message_args (cp_parser* parser) return build_tree_list (error_mark_node, error_mark_node); } - return build_tree_list (sel_args, addl_args); + return build_tree_list (nreverse (sel_args), nreverse (addl_args)); } /* Parse an Objective-C encode expression. |