diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-20 09:09:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-20 09:09:00 +0000 |
commit | f9576738263a1ce2bdd24ae356e749331120182e (patch) | |
tree | 25095a95cd608388f9fefe88f56857730082df70 /vm_insnhelper.c | |
parent | 3a902c4dbd366ddfe696ae0565f0c0174996f9cd (diff) | |
download | ruby-f9576738263a1ce2bdd24ae356e749331120182e.tar.gz |
* vm_insnhelper.c (vm_get_cvar_base): reduce duplicated checks and
move a warning outside the loop.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 13 |
1 files changed, 8 insertions, 5 deletions
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; |