diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-07 05:52:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-07 05:52:15 +0000 |
commit | cf1a22fdf914f96126f5a8b671dab9a69db236f8 (patch) | |
tree | f29f4544c0b908746734dc336209fe13c7850d89 /st.c | |
parent | af01b0fb07af13238cf4a881853d3f8c8787649e (diff) | |
download | ruby-cf1a22fdf914f96126f5a8b671dab9a69db236f8.tar.gz |
* st.c (st_update): table can be unpacked in the callback.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -761,12 +761,21 @@ st_update(st_table *table, st_data_t key, int (*func)(st_data_t key, st_data_t * st_index_t hash_val, bin_pos; register st_table_entry *ptr, **last, *tmp; st_data_t value; + int retval; if (table->entries_packed) { st_index_t i = find_packed_index(table, key); if (i < table->num_entries) { value = PVAL(table, i); - switch ((*func)(key, &value, arg)) { + retval = (*func)(key, &value, arg); + if (!table->entries_packed) { + hash_val = do_hash(key, table); + bin_pos = hash_val % table->num_bins; + ptr = find_entry(table, key, hash_val, bin_pos); + if (ptr == 0) return 0; + goto unpacked; + } + switch (retval) { case ST_CONTINUE: PVAL_SET(table, i, value); break; @@ -787,7 +796,9 @@ st_update(st_table *table, st_data_t key, int (*func)(st_data_t key, st_data_t * } else { value = ptr->record; - switch ((*func)(ptr->key, &value, arg)) { + retval = (*func)(ptr->key, &value, arg); + unpacked: + switch (retval) { case ST_CONTINUE: ptr->record = value; break; |