diff --git a/ChangeLog b/ChangeLog index 14adb17f51..0abb21183d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Sep 20 18:08:51 2011 Nobuyoshi Nakada + + * vm_insnhelper.c (vm_get_cvar_base): reduce duplicated checks and + move a warning outside the loop. + Mon Sep 19 18:55:51 2011 Ayumu AIZAWA * lib/fileutils.rb (module FileUtils): improve performance of diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 98f6ea93e1..9a6661e79b 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1235,14 +1235,17 @@ vm_get_cvar_base(NODE *cref) { VALUE klass; - while (cref && cref->nd_next && + if (!cref) { + rb_bug("vm_get_cvar_base: no cref"); + } + + while (cref->nd_next && (NIL_P(cref->nd_clss) || FL_TEST(cref->nd_clss, FL_SINGLETON) || (cref->flags & NODE_FL_CREF_PUSHED_BY_EVAL))) { cref = cref->nd_next; - - if (!cref->nd_next) { - rb_warn("class variable access from toplevel"); - } + } + if (!cref->nd_next) { + rb_warn("class variable access from toplevel"); } klass = cref->nd_clss;