[前][次][番号順一覧][スレッド一覧]

ruby-changes:39223

From: normal <ko1@a...>
Date: Mon, 20 Jul 2015 15:05:33 +0900 (JST)
Subject: [ruby-changes:39223] normal:r51304 (trunk): parse.y (parser_initialize): avoid redundant zero-ing

normal	2015-07-20 15:05:08 +0900 (Mon, 20 Jul 2015)

  New Revision: 51304

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51304

  Log:
    parse.y (parser_initialize): avoid redundant zero-ing
    
    TypedData_Make_Struct already initializes fields to zero by default,
    so there's no need to waste code re-zeroing them.
    
    Size reduction on 32-bit x86:
    
      text    data     bss     dec     hex filename
     187231    2372      80  189683   2e4f3 parse.o.before
     186939    2372      80  189391   2e3cf parse.o

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51303)
+++ ChangeLog	(revision 51304)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jul 20 15:04:30 2015  Eric Wong  <e@8...>
+
+	* parse.y (parser_initialize): avoid redundant zero-ing
+
 Mon Jul 20 12:12:05 2015  Eric Wong  <e@8...>
 
 	* parse.y (struct parser_params): pack: 88 => 256 bytes on 64-bit
Index: parse.y
===================================================================
--- parse.y	(revision 51303)
+++ parse.y	(revision 51304)
@@ -10547,46 +10547,14 @@ internal_id_gen(struct parser_params *pa https://github.com/ruby/ruby/blob/trunk/parse.y#L10547
 static void
 parser_initialize(struct parser_params *parser)
 {
-    parser->eofp = 0;
-
-    parser->parser_lex_strterm = 0;
-    parser->parser_cond_stack = 0;
-    parser->parser_cmdarg_stack = 0;
-    parser->parser_paren_nest = 0;
-    parser->parser_lpar_beg = 0;
-    parser->parser_brace_nest = 0;
-    parser->parser_in_single = 0;
-    parser->parser_in_def = 0;
-    parser->parser_in_defined = 0;
-    parser->parser_in_kwarg = 0;
-    parser->parser_compile_for_eval = 0;
-    parser->parser_tokenbuf = NULL;
-    parser->parser_tokidx = 0;
-    parser->parser_toksiz = 0;
-    parser->parser_heredoc_end = 0;
+    /* note: we rely on TypedData_Make_Struct to set most fields to 0 */
     parser->parser_command_start = TRUE;
-    parser->parser_deferred_nodes = 0;
-    parser->parser_lex_pbeg = 0;
-    parser->parser_lex_p = 0;
-    parser->parser_lex_pend = 0;
-    parser->parser_lvtbl = 0;
-    parser->parser_ruby__end__seen = 0;
-    parser->parser_ruby_sourcefile = 0;
     parser->parser_ruby_sourcefile_string = Qnil;
-    parser->cur_arg = 0;
-#ifndef RIPPER
-    parser->parser_eval_tree_begin = 0;
-    parser->parser_eval_tree = 0;
-#else
+#ifdef RIPPER
     parser->delayed = Qnil;
-
     parser->result = Qnil;
     parser->parsing_thread = Qnil;
     parser->toplevel_p = TRUE;
-    parser->error_p = FALSE;
-#endif
-#ifdef YYMALLOC
-    parser->heap = NULL;
 #endif
     parser->enc = rb_utf8_encoding();
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]