ruby-changes:22852
From: nobu <ko1@a...>
Date: Mon, 5 Mar 2012 12:44:06 +0900 (JST)
Subject: [ruby-changes:22852] nobu:r34901 (trunk): * st.c: use PACKED_ENT and FIND_ENTRY. patched by Sokolov
nobu 2012-03-05 12:43:55 +0900 (Mon, 05 Mar 2012) New Revision: 34901 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34901 Log: * st.c: use PACKED_ENT and FIND_ENTRY. patched by Sokolov Yura <funny.falcon AT gmail.com>. Modified files: trunk/ChangeLog trunk/st.c Index: ChangeLog =================================================================== --- ChangeLog (revision 34900) +++ ChangeLog (revision 34901) @@ -1,5 +1,8 @@ -Mon Mar 5 12:43:43 2012 Nobuyoshi Nakada <nobu@r...> +Mon Mar 5 12:43:53 2012 Nobuyoshi Nakada <nobu@r...> + * st.c: use PACKED_ENT and FIND_ENTRY. patched by Sokolov + Yura <funny.falcon AT gmail.com>. + * st.c (unpack_entries): reallocate bins if packed array size is not same as initial bins size. based on a patch by Sokolov Yura <funny.falcon AT gmail.com>. Index: st.c =================================================================== --- st.c (revision 34900) +++ st.c (revision 34901) @@ -525,8 +525,7 @@ } hash_val = do_hash(key, table); - bin_pos = hash_val % table->num_bins; - ptr = find_entry(table, key, hash_val, bin_pos); + FIND_ENTRY(table, ptr, hash_val, bin_pos); if (ptr == 0) { add_direct(table, key, value, hash_val, bin_pos); @@ -557,8 +556,7 @@ } hash_val = do_hash(key, table); - bin_pos = hash_val % table->num_bins; - ptr = find_entry(table, key, hash_val, bin_pos); + FIND_ENTRY(table, ptr, hash_val, bin_pos); if (ptr == 0) { key = (*func)(key); @@ -753,8 +751,7 @@ } for (j = i; ++i < table->num_entries;) { if (PKEY(table, i) == never) continue; - PKEY_SET(table, j, PKEY(table, i)); - PVAL_SET(table, j, PVAL(table, i)); + PACKED_ENT(table, j) = PACKED_ENT(table, i); j++; } table->num_entries = j; @@ -791,8 +788,7 @@ 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); + FIND_ENTRY(table, ptr, hash_val, bin_pos); if (ptr == 0) return 0; goto unpacked; } @@ -809,8 +805,7 @@ } hash_val = do_hash(key, table); - bin_pos = hash_val % table->num_bins; - ptr = find_entry(table, key, hash_val, bin_pos); + FIND_ENTRY(table, ptr, hash_val, bin_pos); if (ptr == 0) { return 0; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/