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

ruby-changes:39180

From: normal <ko1@a...>
Date: Thu, 16 Jul 2015 09:04:04 +0900 (JST)
Subject: [ruby-changes:39180] normal:r51261 (trunk): load.c: use fstring for loaded features and expanded load path

normal	2015-07-16 09:03:40 +0900 (Thu, 16 Jul 2015)

  New Revision: 51261

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

  Log:
    load.c: use fstring for loaded features and expanded load path
    
    Loaded features is an obvious candidate for fstring since
    feature paths of Ruby sources are included in iseq locations,
    and iseq locations are in the fstring table anyways.
    
    Deduplicating expanded load path can reuse old objects, since since
    repeated expansions may recycle before old expanded paths are GC-ed
    away.
    
    * load.c (rb_construct_expanded_load_path): fstring expanded path
      (get_loaded_features_index): fstring feature path
      (rb_provide_feature): ditto
      [ruby-core:69871] [Feature #11331]

  Modified files:
    trunk/ChangeLog
    trunk/load.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51260)
+++ ChangeLog	(revision 51261)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jul 16 08:47:29 2015  Eric Wong  <e@8...>
+
+	* load.c (rb_construct_expanded_load_path): fstring expanded path
+	  (get_loaded_features_index): fstring feature path
+	  (rb_provide_feature): ditto
+	  [ruby-core:69871] [Feature #11331]
+
 Thu Jul 16 02:56:14 2015  Eric Wong  <e@8...>
 
 	* thread.c (thread_initialize): avoid RSTRING_PTR and NUMT2INT
Index: load.c
===================================================================
--- load.c	(revision 51260)
+++ load.c	(revision 51261)
@@ -87,7 +87,7 @@ rb_construct_expanded_load_path(int type https://github.com/ruby/ruby/blob/trunk/load.c#L87
 	as_str = rb_get_path_check_convert(path, as_str, level);
 	expanded_path = rb_file_expand_path_fast(as_str, Qnil);
 	rb_str_freeze(expanded_path);
-	rb_ary_push(ary, expanded_path);
+	rb_ary_push(ary, rb_fstring(expanded_path));
     }
     rb_obj_freeze(ary);
     vm->expanded_load_path = ary;
@@ -287,9 +287,9 @@ get_loaded_features_index(void) https://github.com/ruby/ruby/blob/trunk/load.c#L287
 	    VALUE entry, as_str;
 	    as_str = entry = rb_ary_entry(features, i);
 	    StringValue(as_str);
+	    as_str = rb_fstring(rb_str_freeze(as_str));
 	    if (as_str != entry)
 		rb_ary_store(features, i, as_str);
-	    rb_str_freeze(as_str);
 	    features_index_add(as_str, INT2FIX(i));
 	}
 	reset_loaded_features_snapshot();
@@ -560,7 +560,7 @@ rb_provide_feature(VALUE feature) https://github.com/ruby/ruby/blob/trunk/load.c#L560
     }
     rb_str_freeze(feature);
 
-    rb_ary_push(features, feature);
+    rb_ary_push(features, rb_fstring(feature));
     features_index_add(feature, INT2FIX(RARRAY_LEN(features)-1));
     reset_loaded_features_snapshot();
 }

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

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