ruby-changes:18655
From: nobu <ko1@a...>
Date: Thu, 27 Jan 2011 23:30:13 +0900 (JST)
Subject: [ruby-changes:18655] Ruby:r30679 (trunk): * st.c (st_foreach): check if unpacked.
nobu 2011-01-27 23:30:00 +0900 (Thu, 27 Jan 2011) New Revision: 30679 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30679 Log: * st.c (st_foreach): check if unpacked. Modified files: trunk/ChangeLog trunk/st.c Index: ChangeLog =================================================================== --- ChangeLog (revision 30678) +++ ChangeLog (revision 30679) @@ -1,3 +1,7 @@ +Thu Jan 27 23:29:36 2011 Nobuyoshi Nakada <nobu@r...> + + * st.c (st_foreach): check if unpacked. + Thu Jan 27 23:14:19 2011 Nobuyoshi Nakada <nobu@r...> * misc/ruby-mode.el (ruby-mode-map): remove deprecated binding. Index: st.c =================================================================== --- st.c (revision 30678) +++ st.c (revision 30679) @@ -745,6 +745,7 @@ key = (st_data_t)table->bins[i*2]; val = (st_data_t)table->bins[i*2+1]; retval = (*func)(key, val, arg); + if (!table->entries_packed) goto unpacked; switch (retval) { case ST_CHECK: /* check if hash is modified during iteration */ for (j = 0; j < table->num_entries; j++) { @@ -770,9 +771,17 @@ } } return 0; + unpacked: + ptr = table->head; + while (i-- > 0) { + if (!(ptr = ptr->fore)) return 0; + } } + else { + ptr = table->head; + } - if ((ptr = table->head) != 0) { + if (ptr != 0) { do { i = ptr->hash % table->num_bins; retval = (*func)(ptr->key, ptr->record, arg); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/