summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-19 16:58:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-19 16:58:58 +0000
commit963f1bd99084a82b6831455c612a82238eaf08b4 (patch)
tree53e9939e39af1ca6db81bfc2d6011a8bf3a1885a /vm_insnhelper.c
parent398d73c7144c9fac63191ae706c3ba99e810249d (diff)
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
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c9
1 files 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) {