ruby-changes:12902
From: nobu <ko1@a...>
Date: Mon, 24 Aug 2009 16:36:22 +0900 (JST)
Subject: [ruby-changes:12902] Ruby:r24637 (trunk): * st.c (st_delete_safe): deals with packed entries.
nobu 2009-08-24 16:36:02 +0900 (Mon, 24 Aug 2009) New Revision: 24637 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24637 Log: * st.c (st_delete_safe): deals with packed entries. [ruby-core:25080] * st.c (st_cleanup_safe): ditto. [ruby-core:25081] Modified files: trunk/ChangeLog trunk/st.c Index: ChangeLog =================================================================== --- ChangeLog (revision 24636) +++ ChangeLog (revision 24637) @@ -1,3 +1,10 @@ +Mon Aug 24 16:35:57 2009 Nobuyoshi Nakada <nobu@r...> + + * st.c (st_delete_safe): deals with packed entries. + [ruby-core:25080] + + * st.c (st_cleanup_safe): ditto. [ruby-core:25081] + Mon Aug 24 13:24:07 2009 NAKAMURA Usaku <usa@r...> * win32/Makefile.sub (MAKEDIRS): define. Index: st.c =================================================================== --- st.c (revision 24636) +++ st.c (revision 24637) @@ -624,6 +624,19 @@ unsigned int hash_val; register st_table_entry *ptr; + if (table->entries_packed) { + st_index_t i; + for (i = 0; i < table->num_entries; i++) { + if ((st_data_t)table->bins[i*2] == *key) { + if (value != 0) *value = (st_data_t)table->bins[i*2+1]; + table->bins[i*2] = (void *)never; + return 1; + } + } + if (value != 0) *value = 0; + return 0; + } + hash_val = do_hash_bin(*key, table); ptr = table->bins[hash_val]; @@ -647,6 +660,21 @@ st_table_entry *ptr, **last, *tmp; st_index_t i; + if (table->entries_packed) { + st_index_t i = 0, j = 0; + while ((st_data_t)table->bins[i*2] != never) { + if (i++ == table->num_entries) return; + } + for (j = i; ++i < table->num_entries;) { + if ((st_data_t)table->bins[i*2] == never) continue; + table->bins[j*2] = table->bins[i*2]; + table->bins[j*2+1] = table->bins[i*2+1]; + j++; + } + table->num_entries = j; + return; + } + for (i = 0; i < table->num_bins; i++) { ptr = *(last = &table->bins[i]); while (ptr != 0) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/