зеркало из https://github.com/github/ruby.git
Faster rb_class_superclass
This uses the RCLASS_SUPERCLASSES array to quickly find the next SUPERCLASS of klass which is a T_CLASS.
This commit is contained in:
Родитель
58b355175c
Коммит
29b68b89a0
13
object.c
13
object.c
|
@ -2034,19 +2034,18 @@ rb_class_new_instance(int argc, const VALUE *argv, VALUE klass)
|
|||
VALUE
|
||||
rb_class_superclass(VALUE klass)
|
||||
{
|
||||
RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
|
||||
|
||||
VALUE super = RCLASS_SUPER(klass);
|
||||
|
||||
if (!super) {
|
||||
if (klass == rb_cBasicObject) return Qnil;
|
||||
rb_raise(rb_eTypeError, "uninitialized class");
|
||||
} else {
|
||||
super = RCLASS_SUPERCLASSES(klass)[RCLASS_SUPERCLASS_DEPTH(klass) - 1];
|
||||
RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
|
||||
return super;
|
||||
}
|
||||
while (RB_TYPE_P(super, T_ICLASS)) {
|
||||
super = RCLASS_SUPER(super);
|
||||
}
|
||||
if (!super) {
|
||||
return Qnil;
|
||||
}
|
||||
return super;
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
|
Загрузка…
Ссылка в новой задаче