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

ruby-changes:45673

From: normal <ko1@a...>
Date: Wed, 1 Mar 2017 10:16:33 +0900 (JST)
Subject: [ruby-changes:45673] normal:r57745 (trunk): deduplicate strings sooner at load and compile

normal	2017-03-01 10:16:26 +0900 (Wed, 01 Mar 2017)

  New Revision: 57745

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

  Log:
    deduplicate strings sooner at load and compile
    
    We can use rb_fstring_cstr in some places to prevent an
    intermediate object from being created before deduplication
    via rb_fstring.
    
    * compile.c (iseq_compile_each): use rb_fstring_cstr
      (rb_insns_name_array): ditto
    * load.c (rb_load_internal0): ditto

  Modified files:
    trunk/compile.c
    trunk/load.c
Index: compile.c
===================================================================
--- compile.c	(revision 57744)
+++ compile.c	(revision 57745)
@@ -5971,7 +5971,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5971
       }
       case NODE_SCLASS:{
 	ID singletonclass;
-	const rb_iseq_t *singleton_class = NEW_ISEQ(node->nd_body, rb_str_new2("singleton class"),
+	const rb_iseq_t *singleton_class = NEW_ISEQ(node->nd_body, rb_fstring_cstr("singleton class"),
 						    ISEQ_TYPE_CLASS, line);
 
 	CHECK(COMPILE(ret, "sclass#recv", node->nd_recv));
@@ -6515,7 +6515,7 @@ rb_insns_name_array(void) https://github.com/ruby/ruby/blob/trunk/compile.c#L6515
     VALUE ary = rb_ary_new();
     int i;
     for (i = 0; i < numberof(insn_name_info); i++) {
-	rb_ary_push(ary, rb_fstring(rb_str_new2(insn_name_info[i])));
+	rb_ary_push(ary, rb_fstring_cstr(insn_name_info[i]));
     }
     return rb_obj_freeze(ary);
 }
Index: load.c
===================================================================
--- load.c	(revision 57744)
+++ load.c	(revision 57745)
@@ -612,7 +612,8 @@ rb_load_internal0(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/load.c#L612
 	    VALUE parser = rb_parser_new();
 	    rb_parser_set_context(parser, NULL, FALSE);
 	    node = (NODE *)rb_parser_load_file(parser, fname);
-	    iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), NULL);
+	    iseq = rb_iseq_new_top(node, rb_fstring_cstr("<top (required)>"),
+			    fname, rb_realpath_internal(Qnil, fname, 1), NULL);
 	}
 	rb_iseq_eval(iseq);
     }

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

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