* 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
This commit is contained in:
nobu 2014-10-19 16:58:58 +00:00
Родитель 398d73c714
Коммит 963f1bd990
1 изменённых файлов: 3 добавлений и 6 удалений

Просмотреть файл

@ -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)) { if (RB_TYPE_P(obj, T_OBJECT)) {
VALUE val = Qundef; VALUE val = Qundef;
VALUE klass = RBASIC(obj)->klass; 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)) || if (LIKELY(is_attr ? ci->aux.index > 0 : ic->ic_serial == RCLASS_SERIAL(klass))) {
(is_attr && ci->aux.index > 0))) {
int index = !is_attr ? (int)ic->ic_value.index : ci->aux.index - 1; 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) { if (index < len) {
val = ptr[index]; val = ptr[index];
@ -508,8 +507,6 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
} }
else { else {
st_data_t index; 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); struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
if (iv_index_tbl) { if (iv_index_tbl) {