From 48baa71ec691f3dea31e6b5b35a85bb8e7cecc6a Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 7 Aug 2015 12:04:22 +0000 Subject: parse.y: shrink parser_params * parse.y (parser_params): turn in_def and in_single into bit flags and reduce the size by 2-words. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++++- parse.y | 37 +++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index c72be143d4..725462fdd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Fri Aug 7 17:30:19 2015 Nobuyoshi Nakada +Fri Aug 7 21:04:19 2015 Nobuyoshi Nakada + + * parse.y (parser_params): turn in_def and in_single into bit + flags and reduce the size by 2-words. * parse.y (parser_params): remove redundant prefixes. diff --git a/parse.y b/parse.y index 95d279e547..3123e60498 100644 --- a/parse.y +++ b/parse.y @@ -250,8 +250,6 @@ struct parser_params { } lex; stack_type cond_stack; stack_type cmdarg_stack; - int in_single; /* counter */ - int in_def; /* counter */ int tokidx; int toksiz; int tokline; @@ -277,6 +275,8 @@ struct parser_params { unsigned int in_defined: 1; unsigned int compile_for_eval: 1; unsigned int in_kwarg: 1; + unsigned int in_single: 1; + unsigned int in_def: 1; #ifndef RIPPER /* Ruby core only */ @@ -2956,27 +2956,24 @@ primary : literal } | k_class tLSHFT expr { - $$ = in_def; + $$ = (in_def << 1) | in_single; in_def = 0; - } - term - { - $$ = in_single; in_single = 0; local_push(0); } + term bodystmt k_end { /*%%%*/ - $$ = NEW_SCLASS($3, $7); + $$ = NEW_SCLASS($3, $6); fixpos($$, $3); /*% - $$ = dispatch2(sclass, $3, $7); + $$ = dispatch2(sclass, $3, $6); %*/ local_pop(); - in_def = $4; - in_single = $6; + in_def = ($4 >> 1) & 1; + in_single = $4 & 1; } | k_module cpath { @@ -3001,30 +2998,34 @@ primary : literal } | k_def fname { - in_def++; local_push(0); $$ = current_arg; current_arg = 0; } + { + $$ = in_def; + in_def = 1; + } f_arglist bodystmt k_end { /*%%%*/ - NODE *body = remove_begin($5); + NODE *body = remove_begin($6); reduce_nodes(&body); - $$ = NEW_DEFN($2, $4, body, METHOD_VISI_PRIVATE); + $$ = NEW_DEFN($2, $5, body, METHOD_VISI_PRIVATE); nd_set_line($$, $1); /*% - $$ = dispatch3(def, $2, $4, $5); + $$ = dispatch3(def, $2, $5, $6); %*/ local_pop(); - in_def--; + in_def = $4 & 1; current_arg = $3; } | k_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname { - in_single++; + $4 = in_single; + in_single = 1; lex_state = EXPR_ENDFN; /* force for args */ local_push(0); $$ = current_arg; @@ -3043,7 +3044,7 @@ primary : literal $$ = dispatch5(defs, $2, $3, $5, $7, $8); %*/ local_pop(); - in_single--; + in_single = $4 & 1; current_arg = $6; } | keyword_break -- cgit v1.2.3