From: Jakub Jelinek Date: Wed, 22 Jan 2025 08:24:34 +0000 (+0100) Subject: c++: Improve cp_parser_objc_messsage_args compile time X-Git-Tag: basepoints/gcc-16~2433 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14fde9162dfdcd497f17fa799abce1146263893f;p=thirdparty%2Fgcc.git 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 * 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. --- diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index a9eddd1a6da..e1fa7e5ee22 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.