ruby-changes:33773
From: nobu <ko1@a...>
Date: Wed, 7 May 2014 13:27:01 +0900 (JST)
Subject: [ruby-changes:33773] nobu:r45855 (trunk): vm_eval.c: symbol identity
nobu 2014-05-07 13:26:51 +0900 (Wed, 07 May 2014) New Revision: 45855 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45855 Log: vm_eval.c: symbol identity * vm_eval.c (local_var_list_add): use symbol identity, and get rid of method calls. Modified files: trunk/vm_eval.c Index: vm_eval.c =================================================================== --- vm_eval.c (revision 45854) +++ vm_eval.c (revision 45855) @@ -1874,12 +1874,22 @@ rb_catch_protect(VALUE t, rb_block_call_ https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1874 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) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1917 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++) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/