зеркало из https://github.com/github/ruby.git
Move more of GC.latest_gc_info into Ruby
This commit is contained in:
Родитель
461c48960d
Коммит
f8e1c93fe1
13
gc.c
13
gc.c
|
@ -3375,19 +3375,6 @@ rb_gc_latest_gc_info(VALUE key)
|
|||
return rb_gc_impl_latest_gc_info(rb_gc_get_objspace(), key);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
gc_latest_gc_info(rb_execution_context_t *ec, VALUE self, VALUE arg)
|
||||
{
|
||||
if (NIL_P(arg)) {
|
||||
arg = rb_hash_new();
|
||||
}
|
||||
else if (!SYMBOL_P(arg) && !RB_TYPE_P(arg, T_HASH)) {
|
||||
rb_raise(rb_eTypeError, "non-hash or symbol given");
|
||||
}
|
||||
|
||||
return rb_gc_latest_gc_info(arg);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
gc_stat(rb_execution_context_t *ec, VALUE self, VALUE arg) // arg is (nil || hash || symbol)
|
||||
{
|
||||
|
|
10
gc.rb
10
gc.rb
|
@ -320,7 +320,15 @@ module GC
|
|||
# it is overwritten and returned.
|
||||
# This is intended to avoid probe effect.
|
||||
def self.latest_gc_info hash_or_key = nil
|
||||
Primitive.gc_latest_gc_info hash_or_key
|
||||
if hash_or_key == nil
|
||||
hash_or_key = {}
|
||||
elsif Primitive.cexpr!("RBOOL(!SYMBOL_P(hash_or_key) && !RB_TYPE_P(hash_or_key, T_HASH))")
|
||||
raise TypeError, "non-hash or symbol given"
|
||||
end
|
||||
|
||||
Primitive.cstmt! %{
|
||||
return rb_gc_latest_gc_info(hash_or_key);
|
||||
}
|
||||
end
|
||||
|
||||
# call-seq:
|
||||
|
|
Загрузка…
Ссылка в новой задаче