diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-11 09:51:43 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-11 09:51:43 +0000 |
commit | 35f2714452975d567a966b3e8614a203eac8f099 (patch) | |
tree | 556975cb00ac4b40ac198fd128cfa85e2c1bf6cd /vm_insnhelper.c | |
parent | 985a8067cda379847bab32b36c3fd8c54740b42e (diff) |
merge revision(s) 38292: [Backport #6899]
* compile.c (iseq_compile_each): count flip-flop state in local iseq
not in each iseqs, so that the keys can be other than hidden
strings. [ruby-core:47253] [Bug #6899]
* vm_insnhelper.c (lep_svar_get, lep_svar_set, vm_getspecial): store
flip-flop states in an array instead of a hash.
* iseq.c (set_relation): main iseq also can has local scope.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@38317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 55152df2d9..4f709e6291 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -981,7 +981,7 @@ lfp_svar_place(rb_thread_t *th, VALUE *lfp) } static VALUE -lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key) +lfp_svar_get(rb_thread_t *th, VALUE *lfp, rb_num_t key) { NODE *svar = lfp_svar_place(th, lfp); @@ -991,20 +991,20 @@ lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key) case 1: return svar->u2.value; default: { - const VALUE hash = svar->u3.value; + const VALUE ary = svar->u3.value; - if (hash == Qnil) { + if (NIL_P(ary)) { return Qnil; } else { - return rb_hash_lookup(hash, key); + return rb_ary_entry(ary, key - DEFAULT_SPECIAL_VAR_COUNT); } } } } static void -lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val) +lfp_svar_set(rb_thread_t *th, VALUE *lfp, rb_num_t key, VALUE val) { NODE *svar = lfp_svar_place(th, lfp); @@ -1016,27 +1016,23 @@ lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val) svar->u2.value = val; return; default: { - VALUE hash = svar->u3.value; + VALUE ary = svar->u3.value; - if (hash == Qnil) { - svar->u3.value = hash = rb_hash_new(); + if (NIL_P(ary)) { + svar->u3.value = ary = rb_ary_new(); } - rb_hash_aset(hash, key, val); + rb_ary_store(ary, key - DEFAULT_SPECIAL_VAR_COUNT, val); } } } static inline VALUE -vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type) +vm_getspecial(rb_thread_t *th, VALUE *lfp, rb_num_t key, rb_num_t type) { VALUE val; if (type == 0) { - VALUE k = key; - if (FIXNUM_P(key)) { - k = FIX2INT(key); - } - val = lfp_svar_get(th, lfp, k); + val = lfp_svar_get(th, lfp, key); } else { VALUE backref = lfp_svar_get(th, lfp, 1); |