@@ -12589,6 +12589,14 @@ match4(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2,
1258912589 return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4);
1259012590}
1259112591
12592+ /**
12593+ * Returns true if the current token is any of the six given types.
12594+ */
12595+ static PRISM_INLINE bool
12596+ match6(const pm_parser_t *parser, pm_token_type_t type1, pm_token_type_t type2, pm_token_type_t type3, pm_token_type_t type4, pm_token_type_t type5, pm_token_type_t type6) {
12597+ return match1(parser, type1) || match1(parser, type2) || match1(parser, type3) || match1(parser, type4) || match1(parser, type5) || match1(parser, type6);
12598+ }
12599+
1259212600/**
1259312601 * Returns true if the current token is any of the seven given types.
1259412602 */
@@ -15091,6 +15099,16 @@ parse_block(pm_parser_t *parser, uint16_t depth) {
1509115099 */
1509215100static bool
1509315101parse_arguments_list(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_block, uint8_t flags, uint16_t depth) {
15102+ /* Fast path: if the current token can't begin an expression and isn't
15103+ * a parenthesis, block opener, or splat/block-pass operator, there are
15104+ * no arguments to parse. */
15105+ if (
15106+ !token_begins_expression_p(parser->current.type) &&
15107+ !match6(parser, PM_TOKEN_PARENTHESIS_LEFT, PM_TOKEN_KEYWORD_DO, PM_TOKEN_KEYWORD_DO_BLOCK, PM_TOKEN_USTAR, PM_TOKEN_USTAR_STAR, PM_TOKEN_UAMPERSAND)
15108+ ) {
15109+ return false;
15110+ }
15111+
1509415112 bool found = false;
1509515113 bool parsed_command_args = false;
1509615114
0 commit comments