diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-07 04:26:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-07 04:26:51 +0000 |
commit | c8221b4cb6e39d6f022d50a744a1e337941dfc40 (patch) | |
tree | 4abe28218fdaa1f66b56c240c4267e32e95acd27 /vm_eval.c | |
parent | 766478f6a781cb4c1f5f9f9e1f5a0751745ec040 (diff) | |
download | ruby-c8221b4cb6e39d6f022d50a744a1e337941dfc40.tar.gz |
vm_eval.c: symbol identity
* vm_eval.c (local_var_list_add): use symbol identity, and get rid
of method calls.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r-- | vm_eval.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1874,12 +1874,22 @@ rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr) return val; } +static int +local_var_list_update(st_data_t *key, st_data_t *value, st_data_t arg, int existing) +{ + if (existing) return ST_STOP; + *value = (st_data_t)Qtrue; /* INT2FIX(arg) */ + return ST_CONTINUE; +} + static void local_var_list_add(const struct local_var_list *vars, ID lid) { if (lid && rb_id2str(lid)) { /* should skip temporary variable */ - rb_hash_aset(vars->tbl, ID2SYM(lid), Qtrue); + st_table *tbl = RHASH_TBL_RAW(vars->tbl); + st_data_t idx = 0; /* tbl->num_entries */ + st_update(tbl, ID2SYM(lid), local_var_list_update, idx); } } @@ -1907,6 +1917,7 @@ rb_f_local_variables(void) int i; vars.tbl = rb_hash_new(); + RHASH(vars.tbl)->ntbl = st_init_numtable(); /* compare_by_identity */ while (cfp) { if (cfp->iseq) { for (i = 0; i < cfp->iseq->local_table_size; i++) { |