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

ruby-changes:34542

From: ko1 <ko1@a...>
Date: Mon, 30 Jun 2014 16:47:07 +0900 (JST)
Subject: [ruby-changes:34542] ko1:r46623 (trunk): * gc.c (gc_stat_internal): return size_t value instead of VALUE

ko1	2014-06-30 16:46:57 +0900 (Mon, 30 Jun 2014)

  New Revision: 46623

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

  Log:
    * gc.c (gc_stat_internal): return size_t value instead of VALUE
      and remove `out' parameter.
    * gc.c: add braces for `if' statements.
    * gc.c (gc_stat_internal): fix comment.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46622)
+++ ChangeLog	(revision 46623)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 30 16:42:52 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_stat_internal): return size_t value instead of VALUE
+	  and remove `out' parameter.
+
+	* gc.c: add braces for `if' statements.
+
+	* gc.c (gc_stat_internal): fix comment.
+
 Mon Jun 30 15:07:34 2014  Koichi Sasada  <ko1@a...>
 
 	* gc.c: support `USE_RGENGC == 0'.
Index: gc.c
===================================================================
--- gc.c	(revision 46622)
+++ gc.c	(revision 46623)
@@ -5555,14 +5555,15 @@ gc_latest_gc_info(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/gc.c#L5555
 	}
     }
 
-    if (arg == Qnil)
-        arg = rb_hash_new();
+    if (arg == Qnil) {
+	arg = rb_hash_new();
+    }
 
     return gc_info_decode(objspace->profile.latest_gc_info, arg);
 }
 
-static VALUE
-gc_stat_internal(VALUE hash_or_sym, size_t *out)
+size_t
+gc_stat_internal(VALUE hash_or_sym)
 {
     static VALUE sym_count;
     static VALUE sym_heap_used, sym_heap_length, sym_heap_increment;
@@ -5590,12 +5591,15 @@ gc_stat_internal(VALUE hash_or_sym, size https://github.com/ruby/ruby/blob/trunk/gc.c#L5591
     rb_objspace_t *objspace = &rb_objspace;
     VALUE hash = Qnil, key = Qnil;
 
-    if (RB_TYPE_P(hash_or_sym, T_HASH))
+    if (RB_TYPE_P(hash_or_sym, T_HASH)) {
 	hash = hash_or_sym;
-    else if (SYMBOL_P(hash_or_sym) && out)
+    }
+    else if (SYMBOL_P(hash_or_sym)) {
 	key = hash_or_sym;
-    else
+    }
+    else {
 	rb_raise(rb_eTypeError, "non-hash or symbol argument");
+    }
 
     if (sym_count == 0) {
 #define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
@@ -5635,14 +5639,14 @@ gc_stat_internal(VALUE hash_or_sym, size https://github.com/ruby/ruby/blob/trunk/gc.c#L5639
 	S(promote_young_count);
 	S(remembered_normal_object_count);
 	S(remembered_shady_object_count);
-#endif /* USE_RGENGC */
 #endif /* RGENGC_PROFILE */
+#endif /* USE_RGENGC */
 #undef S
     }
 
 #define SET(name, attr) \
     if (key == sym_##name) \
-	return (*out = attr, Qnil); \
+	return attr; \
     else if (hash != Qnil) \
 	rb_hash_aset(hash, sym_##name, SIZET2NUM(attr));
 
@@ -5709,7 +5713,7 @@ gc_stat_internal(VALUE hash_or_sym, size https://github.com/ruby/ruby/blob/trunk/gc.c#L5713
     }
 #endif
 
-    return hash;
+    return 0;
 }
 
 /*
@@ -5759,8 +5763,7 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L5763
 
     if (rb_scan_args(argc, argv, "01", &arg) == 1) {
 	if (SYMBOL_P(arg)) {
-	    size_t value = 0;
-	    gc_stat_internal(arg, &value);
+	    size_t value = gc_stat_internal(arg);
 	    return SIZET2NUM(value);
 	}
 	else if (!RB_TYPE_P(arg, T_HASH)) {
@@ -5771,7 +5774,7 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L5774
     if (arg == Qnil) {
         arg = rb_hash_new();
     }
-    gc_stat_internal(arg, 0);
+    gc_stat_internal(arg);
     return arg;
 }
 
@@ -5779,12 +5782,11 @@ size_t https://github.com/ruby/ruby/blob/trunk/gc.c#L5782
 rb_gc_stat(VALUE key)
 {
     if (SYMBOL_P(key)) {
-	size_t value = 0;
-	gc_stat_internal(key, &value);
+	size_t value = gc_stat_internal(key);
 	return value;
     }
     else {
-	gc_stat_internal(key, 0);
+	gc_stat_internal(key);
 	return 0;
     }
 }

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

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