Skip to content

Commit

Permalink
* st.c (unpack_entries): Fix r34310: on unpacking, the position of
Browse files Browse the repository at this point in the history
  a hash must be do_hash-ed value.

* st.c (add_packed_direct): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed Jan 16, 2012
1 parent de1e488 commit 84f2040
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Tue Jan 17 07:30:12 2012 NARUSE, Yui <[email protected]>

* st.c (unpack_entries): Fix r34310: on unpacking, the position of
a hash must be do_hash-ed value.

* st.c (add_packed_direct): ditto.

Mon Jan 16 16:41:53 2012 Nobuyoshi Nakada <[email protected]>

* lib/optparse.rb (Regexp): fix incorrect options when casting to
Expand Down
5 changes: 3 additions & 2 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ unpack_entries(register st_table *table)
tmp_table.num_entries = 0;
memset(tmp_table.bins, 0, sizeof(struct st_table_entry *) * tmp_table.num_bins);
for (i = 0; i < table->num_entries; i++) {
st_index_t hash_val = PKEY(table, i); /* do_hash(PKEY(table, i), &tmp_table); */
st_index_t hash_val = do_hash(PKEY(table, i), &tmp_table);
add_direct(&tmp_table, PKEY(table, i), PVAL(table, i),
hash_val, hash_val % tmp_table.num_bins);
}
Expand All @@ -478,8 +478,9 @@ add_packed_direct(st_table *table, st_data_t key, st_data_t value)
PVAL_SET(table, i, value);
}
else {
st_index_t hash_val = do_hash(key, table);
unpack_entries(table);
add_direct(table, key, value, key, key % table->num_bins);
add_direct(table, key, value, hash_val, hash_val % table->num_bins);
}
}

Expand Down

0 comments on commit 84f2040

Please sign in to comment.