ruby-changes:69545
From: Nobuyoshi <ko1@a...>
Date: Sun, 31 Oct 2021 15:16:47 +0900 (JST)
Subject: [ruby-changes:69545] 1b59ad57ae (master): Reduce parser stack usage at pattern matching
https://git.ruby-lang.org/ruby.git/commit/?id=1b59ad57ae From 1b59ad57ae2fa4cfccaab97f22f943333080ea0c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 31 Oct 2021 13:49:21 +0900 Subject: Reduce parser stack usage at pattern matching --- parse.y | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/parse.y b/parse.y index ec25402aecc..14393abad08 100644 --- a/parse.y +++ b/parse.y @@ -1758,36 +1758,36 @@ expr : command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1758 value_expr($1); SET_LEX_STATE(EXPR_BEG|EXPR_LABEL); p->command_start = FALSE; - $<ctxt>$ = p->ctxt; + $<ctxt>2 = p->ctxt; p->ctxt.in_kwarg = 1; + $<tbl>$ = push_pvtbl(p); } - {$<tbl>$ = push_pvtbl(p);} p_top_expr_body - {pop_pvtbl(p, $<tbl>4);} { - p->ctxt.in_kwarg = $<ctxt>3.in_kwarg; + pop_pvtbl(p, $<tbl>3); + p->ctxt.in_kwarg = $<ctxt>2.in_kwarg; /*%%%*/ - $$ = NEW_CASE3($1, NEW_IN($5, 0, 0, &@5), &@$); + $$ = NEW_CASE3($1, NEW_IN($4, 0, 0, &@4), &@$); /*% %*/ - /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/ + /*% ripper: case!($1, in!($4, Qnil, Qnil)) %*/ } | arg keyword_in { value_expr($1); SET_LEX_STATE(EXPR_BEG|EXPR_LABEL); p->command_start = FALSE; - $<ctxt>$ = p->ctxt; + $<ctxt>2 = p->ctxt; p->ctxt.in_kwarg = 1; + $<tbl>$ = push_pvtbl(p); } - {$<tbl>$ = push_pvtbl(p);} p_top_expr_body - {pop_pvtbl(p, $<tbl>4);} { - p->ctxt.in_kwarg = $<ctxt>3.in_kwarg; + pop_pvtbl(p, $<tbl>3); + p->ctxt.in_kwarg = $<ctxt>1.in_kwarg; /*%%%*/ - $$ = NEW_CASE3($1, NEW_IN($5, NEW_TRUE(&@5), NEW_FALSE(&@5), &@5), &@$); + $$ = NEW_CASE3($1, NEW_IN($4, NEW_TRUE(&@4), NEW_FALSE(&@4), &@4), &@$); /*% %*/ - /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/ + /*% ripper: case!($1, in!($4, Qnil, Qnil)) %*/ } | arg %prec tLBRACE_ARG ; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/