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

ruby-changes:25258

From: ko1 <ko1@a...>
Date: Wed, 24 Oct 2012 12:00:52 +0900 (JST)
Subject: [ruby-changes:25258] ko1:r37310 (trunk): * ext/objspace/objspace.c (reachable_object_from_i): change data

ko1	2012-10-24 12:00:39 +0900 (Wed, 24 Oct 2012)

  New Revision: 37310

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

  Log:
    * ext/objspace/objspace.c (reachable_object_from_i): change data
      structure of the result of reachable objects. Keys of table
      contains object_id of each reachable objects. Value of table
      is an object itself or an instance of InternalObjectWrapper.
      To avoid duplication, we use st_table and object_id keys.
    * ext/objspace/objspace.c (type2sym): bug fix.
      Should use `i' instead of `type'.

  Modified files:
    trunk/ChangeLog
    trunk/ext/objspace/objspace.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37309)
+++ ChangeLog	(revision 37310)
@@ -1,3 +1,14 @@
+Wed Oct 24 11:55:19 2012  Koichi Sasada  <ko1@a...>
+
+	* ext/objspace/objspace.c (reachable_object_from_i): change data
+	  structure of the result of reachable objects. Keys of table
+	  contains object_id of each reachable objects. Value of table
+	  is an object itself or an instance of InternalObjectWrapper.
+	  To avoid duplication, we use st_table and object_id keys.
+
+	* ext/objspace/objspace.c (type2sym): bug fix.
+	  Should use `i' instead of `type'.
+
 Wed Oct 24 10:33:09 2012  Koichi Sasada  <ko1@a...>
 
 	* gc.c (garbage_collect, gc_marks): move the location of
Index: ext/objspace/objspace.c
===================================================================
--- ext/objspace/objspace.c	(revision 37309)
+++ ext/objspace/objspace.c	(revision 37310)
@@ -302,7 +302,7 @@
 	CASE_TYPE(T_ICLASS);
 	CASE_TYPE(T_ZOMBIE);
 #undef CASE_TYPE
-      default: rb_bug("type2sym: unknown type (%d)", (int)type);
+      default: rb_bug("type2sym: unknown type (%d)", i);
     }
     return type;
 }
@@ -684,21 +684,23 @@
 reachable_object_from_i(VALUE obj, void *data_ptr)
 {
     struct rof_data *data = (struct rof_data *)data_ptr;
+    VALUE key = obj;
+    VALUE val = obj;
 
     if (rb_objspace_markable_object_p(obj)) {
 	if (rb_objspace_internal_object_p(obj)) {
-	    obj = iow_newobj(obj);
-	    rb_ary_push(data->internals, obj);
+	    val = iow_newobj(obj);
+	    rb_ary_push(data->internals, val);
 	}
-	st_insert(data->refs, obj, Qtrue);
+	st_insert(data->refs, key, val);
     }
 }
 
 static int
-collect_keys(st_data_t key, st_data_t value, st_data_t data)
+collect_values(st_data_t key, st_data_t value, st_data_t data)
 {
     VALUE ary = (VALUE)data;
-    rb_ary_push(ary, (VALUE)key);
+    rb_ary_push(ary, (VALUE)value);
     return ST_CONTINUE;
 }
 
@@ -759,7 +761,7 @@
 
 	rb_objspace_reachable_objects_from(obj, reachable_object_from_i, &data);
 
-	st_foreach(data.refs, collect_keys, (st_data_t)ret);
+	st_foreach(data.refs, collect_values, (st_data_t)ret);
 	return ret;
     }
     else {

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

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