1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

parse.y: shrink parser_params

* parse.y (struct parser_params): reduce size by reordering
  members and an unused member.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-11-19 23:54:59 +00:00
parent 4cb3f72fdd
commit 6f4e3f05f5
2 changed files with 28 additions and 20 deletions

View file

@ -1,3 +1,8 @@
Thu Nov 20 08:54:56 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (struct parser_params): reduce size by reordering
members and an unused member.
Thu Nov 20 02:44:27 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca> Thu Nov 20 02:44:27 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/matrix.rb: Vector#independent? and associated class method * lib/matrix.rb: Vector#independent? and associated class method

43
parse.y
View file

@ -236,11 +236,10 @@ struct parser_params {
int parser_compile_for_eval; int parser_compile_for_eval;
int parser_in_kwarg; int parser_in_kwarg;
int parser_in_defined; int parser_in_defined;
char *parser_tokenbuf;
int parser_tokidx; int parser_tokidx;
int parser_toksiz; int parser_toksiz;
int parser_tokline; int parser_tokline;
int is_ripper; /* bool, seems unused */ char *parser_tokenbuf;
VALUE parser_lex_input; VALUE parser_lex_input;
VALUE parser_lex_lastline; VALUE parser_lex_lastline;
VALUE parser_lex_nextline; VALUE parser_lex_nextline;
@ -253,32 +252,36 @@ struct parser_params {
long parser_lex_gets_ptr; long parser_lex_gets_ptr;
VALUE (*parser_lex_gets)(struct parser_params*,VALUE); VALUE (*parser_lex_gets)(struct parser_params*,VALUE);
struct local_vars *parser_lvtbl; struct local_vars *parser_lvtbl;
int parser_ruby__end__seen;
int line_count; int line_count;
int has_shebang;
int parser_ruby_sourceline; /* current line no. */ int parser_ruby_sourceline; /* current line no. */
char *parser_ruby_sourcefile; /* current source file */ char *parser_ruby_sourcefile; /* current source file */
VALUE parser_ruby_sourcefile_string; VALUE parser_ruby_sourcefile_string;
rb_encoding *enc; rb_encoding *enc;
int parser_yydebug; ID cur_arg;
int last_cr_line; int last_cr_line;
ID cur_arg; unsigned int parser_ruby__end__seen: 1;
unsigned int parser_yydebug: 1;
unsigned int has_shebang: 1;
#ifndef RIPPER #ifndef RIPPER
/* Ruby core only */ /* Ruby core only */
unsigned int parser_token_info_enabled: 1;
int nerr;
NODE *parser_eval_tree_begin; NODE *parser_eval_tree_begin;
NODE *parser_eval_tree; NODE *parser_eval_tree;
VALUE debug_lines; VALUE debug_lines;
VALUE coverage; VALUE coverage;
int nerr;
int parser_token_info_enabled;
token_info *parser_token_info; token_info *parser_token_info;
#else #else
/* Ripper only */ /* Ripper only */
unsigned int toplevel_p: 1;
unsigned int error_p: 1;
const char *tokp; const char *tokp;
VALUE delayed; VALUE delayed;
int delayed_line; int delayed_line;
@ -287,8 +290,6 @@ struct parser_params {
VALUE value; VALUE value;
VALUE result; VALUE result;
VALUE parsing_thread; VALUE parsing_thread;
int toplevel_p;
int error_p;
#endif #endif
}; };
@ -6837,26 +6838,30 @@ magic_comment_encoding(struct parser_params *parser, const char *name, const cha
parser_set_encode(parser, val); parser_set_encode(parser, val);
} }
static void static int
parser_set_token_info(struct parser_params *parser, const char *name, const char *val) parser_get_bool(struct parser_params *parser, const char *name, const char *val)
{ {
int *p = &parser->parser_token_info_enabled;
switch (*val) { switch (*val) {
case 't': case 'T': case 't': case 'T':
if (strcasecmp(val, "true") == 0) { if (strcasecmp(val, "true") == 0) {
*p = TRUE; return TRUE;
return;
} }
break; break;
case 'f': case 'F': case 'f': case 'F':
if (strcasecmp(val, "false") == 0) { if (strcasecmp(val, "false") == 0) {
*p = FALSE; return FALSE;
return;
} }
break; break;
} }
rb_compile_warning(ruby_sourcefile, ruby_sourceline, "invalid value for %s: %s", name, val); rb_compile_warning(ruby_sourcefile, ruby_sourceline, "invalid value for %s: %s", name, val);
return -1;
}
static void
parser_set_token_info(struct parser_params *parser, const char *name, const char *val)
{
int b = parser_get_bool(parser, name, val);
if (b >= 0) parser->parser_token_info_enabled = b;
} }
struct magic_comment { struct magic_comment {
@ -10423,11 +10428,9 @@ parser_initialize(struct parser_params *parser)
parser->parser_ruby_sourcefile_string = Qnil; parser->parser_ruby_sourcefile_string = Qnil;
parser->cur_arg = 0; parser->cur_arg = 0;
#ifndef RIPPER #ifndef RIPPER
parser->is_ripper = 0;
parser->parser_eval_tree_begin = 0; parser->parser_eval_tree_begin = 0;
parser->parser_eval_tree = 0; parser->parser_eval_tree = 0;
#else #else
parser->is_ripper = 1;
parser->delayed = Qnil; parser->delayed = Qnil;
parser->result = Qnil; parser->result = Qnil;