ruby-changes:58918
From: Nobuyoshi <ko1@a...>
Date: Tue, 26 Nov 2019 23:09:30 +0900 (JST)
Subject: [ruby-changes:58918] 22dfd14c17 (master): Hoisted out `push_pvtbl`/`pop_pvtbl`
https://git.ruby-lang.org/ruby.git/commit/?id=22dfd14c17 From 22dfd14c179632d773b97e708255b6c183a740aa Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 26 Nov 2019 15:40:34 +0900 Subject: Hoisted out `push_pvtbl`/`pop_pvtbl` diff --git a/parse.y b/parse.y index 154c76f..5b73fa0 100644 --- a/parse.y +++ b/parse.y @@ -324,6 +324,21 @@ struct parser_params { https://github.com/ruby/ruby/blob/trunk/parse.y#L324 #define STR_NEW3(ptr,len,e,func) parser_str_new((ptr),(len),(e),(func),p->enc) #define TOK_INTERN() intern_cstr(tok(p), toklen(p), p->enc) +static st_table * +push_pvtbl(struct parser_params *p) +{ + st_table *tbl = p->pvtbl; + p->pvtbl = st_init_numtable(); + return tbl; +} + +static void +pop_pvtbl(struct parser_params *p, st_table *tbl) +{ + st_free_table(p->pvtbl); + p->pvtbl = tbl; +} + static int parser_yyerror(struct parser_params*, const YYLTYPE *yylloc, const char*); #define yyerror0(msg) parser_yyerror(p, NULL, (msg)) #define yyerror1(loc, msg) parser_yyerror(p, (loc), (msg)) @@ -1566,15 +1581,9 @@ expr : command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1581 $<num>$ = p->in_kwarg; p->in_kwarg = 1; } - { - $<tbl>$ = p->pvtbl; - p->pvtbl = st_init_numtable(); - } + {$<tbl>$ = push_pvtbl(p);} p_expr - { - st_free_table(p->pvtbl); - p->pvtbl = $<tbl>4; - } + {pop_pvtbl(p, $<tbl>4);} { p->in_kwarg = !!$<num>3; /*%%%*/ @@ -3798,15 +3807,9 @@ p_case_body : keyword_in https://github.com/ruby/ruby/blob/trunk/parse.y#L3807 $<num>$ = p->in_kwarg; p->in_kwarg = 1; } - { - $<tbl>$ = p->pvtbl; - p->pvtbl = st_init_numtable(); - } + {$<tbl>$ = push_pvtbl(p);} p_top_expr then - { - st_free_table(p->pvtbl); - p->pvtbl = $<tbl>3; - } + {pop_pvtbl(p, $<tbl>3);} { p->in_kwarg = !!$<num>2; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/