summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-07 03:58:01 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-07 03:58:01 +0000
commita383ffa07b4641f6e19500e95cf9388af05e510c (patch)
tree971951b52ac3656d9eff316985b46011b10adcb4 /st.c
parentd2d9d6ef1764f5e2f0b2ae0f6a96230b4332d67d (diff)
merge revision(s) 45642,45643: [Backport #9646] [Backport #9729]
* st.c (st_foreach_check): chnage start point of search at check from top to current. [ruby-dev:48047] [Bug #9646] * st.c (st_foreach_check): change start point of search at check git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r--st.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/st.c b/st.c
index c5550bc673..6b97a11091 100644
--- a/st.c
+++ b/st.c
@@ -393,9 +393,8 @@ find_entry(st_table *table, st_data_t key, st_index_t hash_val, st_index_t bin_p
}
static inline st_index_t
-find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
+find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key, st_index_t i)
{
- st_index_t i = 0;
while (i < table->real_entries &&
(PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) {
i++;
@@ -403,6 +402,12 @@ find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
return i;
}
+static inline st_index_t
+find_packed_index(st_table *table, st_index_t hash_val, st_data_t key)
+{
+ return find_packed_index_from(table, hash_val, key, 0);
+}
+
#define collision_check 0
int
@@ -934,9 +939,10 @@ st_foreach_check(st_table *table, int (*func)(ANYARGS), st_data_t arg, st_data_t
if (PHASH(table, i) == 0 && PKEY(table, i) == never) {
break;
}
- i = find_packed_index(table, hash, key);
- if (i == table->real_entries) {
- goto deleted;
+ i = find_packed_index_from(table, hash, key, i);
+ if (i >= table->real_entries) {
+ i = find_packed_index(table, hash, key);
+ if (i >= table->real_entries) goto deleted;
}
/* fall through */
case ST_CONTINUE: