diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 36 |
1 files changed, 2 insertions, 34 deletions
@@ -1776,45 +1776,13 @@ ruby_current_class_object() static VALUE ev_const_defined(ID id, VALUE self) { - NODE *cbase = ruby_cref; - VALUE result; - - while (cbase && cbase->nd_next) { - struct RClass *klass = RCLASS(cbase->nd_clss); - - if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id); - if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { - if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) { - return Qfalse; - } - return Qtrue; - } - cbase = cbase->nd_next; - } - return rb_const_defined(ruby_cbase, id); + return rb_const_defined_fallback(ruby_cbase, id, ruby_cref->nd_next); } static VALUE ev_const_get(ID id, VALUE self) { - NODE *cbase = ruby_cref; - VALUE result; - - while (cbase && cbase->nd_next) { - VALUE klass = cbase->nd_clss; - - if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id); - while (RCLASS(klass)->iv_tbl && - st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { - if (result == Qundef) { - if (!RTEST(rb_autoload_load(klass, id))) break; - continue; - } - return result; - } - cbase = cbase->nd_next; - } - return rb_const_get(ruby_cbase, id); + return rb_const_get_fallback(ruby_cbase, id, ruby_cref->nd_next); } static VALUE |