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

ruby-changes:45232

From: nobu <ko1@a...>
Date: Wed, 11 Jan 2017 13:13:04 +0900 (JST)
Subject: [ruby-changes:45232] nobu:r57305 (trunk): variable.c: fix the condition to cache

nobu	2017-01-11 13:12:56 +0900 (Wed, 11 Jan 2017)

  New Revision: 57305

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

  Log:
    variable.c: fix the condition to cache
    
    * variable.c (rb_const_set): fix the condition to cache the class
      path and cache permanent or temporary path corresponding to the
      outer klass.  [ruby-core:79039] [Bug #13120]

  Modified files:
    trunk/variable.c
Index: variable.c
===================================================================
--- variable.c	(revision 57304)
+++ variable.c	(revision 57305)
@@ -2612,10 +2612,25 @@ rb_const_set(VALUE klass, ID id, VALUE v https://github.com/ruby/ruby/blob/trunk/variable.c#L2612
      * and avoid order-dependency on const_tbl
      */
     if (rb_cObject && (RB_TYPE_P(val, T_MODULE) || RB_TYPE_P(val, T_CLASS))) {
-	if (!NIL_P(rb_class_path_cached(val))) {
-	    rb_name_class(val, id);
-	    if (rb_class_path_cached(klass)) {
-		rb_class_name(val);
+	if (NIL_P(rb_class_path_cached(val))) {
+	    if (klass == rb_cObject) {
+		rb_ivar_set(val, classpath, rb_id2str(id));
+		rb_name_class(val, id);
+	    }
+	    else {
+		VALUE path;
+		ID pathid;
+		st_data_t n;
+		st_table *ivtbl = RCLASS_IV_TBL(klass);
+		if (ivtbl &&
+		    (st_lookup(ivtbl, (st_data_t)(pathid = classpath), &n) ||
+		     st_lookup(ivtbl, (st_data_t)(pathid = tmp_classpath), &n))) {
+		    path = rb_str_dup((VALUE)n);
+		    rb_str_append(rb_str_cat2(path, "::"), rb_id2str(id));
+		    OBJ_FREEZE(path);
+		    rb_ivar_set(val, pathid, path);
+		    rb_name_class(val, id);
+		}
 	    }
 	}
     }

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

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