aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-22 09:47:34 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-22 09:47:34 +0000
commite7995cb0f8c943bd2b836ba834baae52e922eb1d (patch)
tree48affa2e12a107e94b6164de6358eb2b765ccf46 /vm_insnhelper.c
parent3621c3fe73f128ea7f651d92a2ecacdd24e40c58 (diff)
downloadruby-e7995cb0f8c943bd2b836ba834baae52e922eb1d.tar.gz
* variable.c: use uint32_t instead of long to avoid confusion about
the type of ivtbl->numiv. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 0176bb372e..0f27c9ee23 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -781,11 +781,11 @@ vm_getivar(VALUE obj, ID id, IC ic, struct rb_call_cache *cc, 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 uint32_t len = ROBJECT_NUMIV(obj);
const VALUE *const ptr = ROBJECT_IVPTR(obj);
if (LIKELY(is_attr ? cc->aux.index > 0 : ic->ic_serial == RCLASS_SERIAL(klass))) {
- long index = !is_attr ? (long)ic->ic_value.index : (long)(cc->aux.index - 1);
+ st_index_t index = !is_attr ? ic->ic_value.index : (cc->aux.index - 1);
if (index < len) {
val = ptr[index];
@@ -797,7 +797,7 @@ vm_getivar(VALUE obj, ID id, IC ic, struct rb_call_cache *cc, int is_attr)
if (iv_index_tbl) {
if (st_lookup(iv_index_tbl, id, &index)) {
- if ((long)index < len) {
+ if (index < len) {
val = ptr[index];
}
if (!is_attr) {
@@ -837,11 +837,10 @@ vm_setivar(VALUE obj, ID id, VALUE val, IC ic, struct rb_call_cache *cc, int is_
if (LIKELY(
(!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) ||
(is_attr && cc->aux.index > 0))) {
- long index = !is_attr ? (long)ic->ic_value.index : (long)cc->aux.index-1;
- long len = ROBJECT_NUMIV(obj);
VALUE *ptr = ROBJECT_IVPTR(obj);
+ index = !is_attr ? ic->ic_value.index : cc->aux.index-1;
- if (index < len) {
+ if (index < ROBJECT_NUMIV(obj)) {
RB_OBJ_WRITE(obj, &ptr[index], val);
return val; /* inline cache hit */
}