From 963f1bd99084a82b6831455c612a82238eaf08b4 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 19 Oct 2014 16:58:58 +0000 Subject: [PATCH] vm_insnhelper.c: refactoring * vm_insnhelper.c (vm_getivar): move common expressions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 05ed3c62aa..41c1d0678c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -495,12 +495,11 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr) if (RB_TYPE_P(obj, T_OBJECT)) { VALUE val = Qundef; VALUE klass = RBASIC(obj)->klass; + const long len = ROBJECT_NUMIV(obj); + const VALUE *const ptr = ROBJECT_IVPTR(obj); - if (LIKELY((!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) || - (is_attr && ci->aux.index > 0))) { + if (LIKELY(is_attr ? ci->aux.index > 0 : ic->ic_serial == RCLASS_SERIAL(klass))) { int index = !is_attr ? (int)ic->ic_value.index : ci->aux.index - 1; - long len = ROBJECT_NUMIV(obj); - VALUE *ptr = ROBJECT_IVPTR(obj); if (index < len) { val = ptr[index]; @@ -508,8 +507,6 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr) } else { st_data_t index; - long len = ROBJECT_NUMIV(obj); - VALUE *ptr = ROBJECT_IVPTR(obj); struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj); if (iv_index_tbl) {