summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-30 07:46:57 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-30 07:46:57 +0000
commit51ae29a3cb4ee5821b2cdbd3fbdbb910c803a847 (patch)
tree494924c4f776769a0f636cae05f68aa2aced7846 /gc.c
parent4369806ff0ef10833f31897ae97527079d56897f (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/gc.c b/gc.c
index c435c102a0..565eba4ea0 100644
--- a/gc.c
+++ b/gc.c
@@ -5555,14 +5555,15 @@ gc_latest_gc_info(int argc, VALUE *argv, VALUE self)
}
}
- 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_t *out)
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_t *out)
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_t *out)
}
#endif
- return hash;
+ return 0;
}
/*
@@ -5759,8 +5763,7 @@ gc_stat(int argc, VALUE *argv, VALUE self)
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 self)
if (arg == Qnil) {
arg = rb_hash_new();
}
- gc_stat_internal(arg, 0);
+ gc_stat_internal(arg);
return arg;
}
@@ -5779,12 +5782,11 @@ size_t
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;
}
}