ruby-changes:39283
From: nobu <ko1@a...>
Date: Fri, 24 Jul 2015 21:30:13 +0900 (JST)
Subject: [ruby-changes:39283] nobu:r51364 (trunk): st.c: fix arguments order to compare
nobu 2015-07-24 21:29:57 +0900 (Fri, 24 Jul 2015) New Revision: 51364 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51364 Log: st.c: fix arguments order to compare * st.c (EQUAL, st_delete_safe): fix arguments order to compare function, searching key is the first and stored key is the second always. Modified files: trunk/ChangeLog trunk/st.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51363) +++ ChangeLog (revision 51364) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jul 24 21:29:54 2015 Nobuyoshi Nakada <nobu@r...> + + * st.c (EQUAL, st_delete_safe): fix arguments order to compare + function, searching key is the first and stored key is the + second always. + Fri Jul 24 21:27:29 2015 Nobuyoshi Nakada <nobu@r...> * string.c (fstr_update_callback): fstring must not be a shared Index: st.c =================================================================== --- st.c (revision 51363) +++ st.c (revision 51364) @@ -86,7 +86,7 @@ static void rehash(st_table *); https://github.com/ruby/ruby/blob/trunk/st.c#L86 #define free(x) xfree(x) #endif -#define EQUAL(table,x,y) ((x)==(y) || (*(table)->type->compare)((x),(y)) == 0) +#define EQUAL(table,x,ent) ((x)==(ent)->key || (*(table)->type->compare)((x),(ent)->key) == 0) #define do_hash(key,table) (st_index_t)(*(table)->type->hash)((key)) #define hash_pos(h,n) ((h) & (n - 1)) @@ -319,7 +319,7 @@ st_memsize(const st_table *table) https://github.com/ruby/ruby/blob/trunk/st.c#L319 } #define PTR_NOT_EQUAL(table, ptr, hash_val, key) \ -((ptr) != 0 && ((ptr)->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key))) +((ptr) != 0 && ((ptr)->hash != (hash_val) || !EQUAL((table), (key), (ptr)))) #ifdef HASH_LOG static void @@ -365,7 +365,7 @@ static inline st_index_t https://github.com/ruby/ruby/blob/trunk/st.c#L365 find_packed_index_from(st_table *table, st_index_t hash_val, st_data_t key, st_index_t i) { while (i < table->real_entries && - (PHASH(table, i) != hash_val || !EQUAL(table, key, PKEY(table, i)))) { + (PHASH(table, i) != hash_val || !EQUAL(table, key, &PACKED_ENT(table, i)))) { i++; } return i; @@ -685,7 +685,7 @@ st_delete(register st_table *table, regi https://github.com/ruby/ruby/blob/trunk/st.c#L685 prev = &table->bins[hash_pos(hash_val, table->num_bins)]; for (;(ptr = *prev) != 0; prev = &ptr->next) { - if (EQUAL(table, *key, ptr->key)) { + if (EQUAL(table, *key, ptr)) { *prev = ptr->next; remove_entry(table, ptr); if (value != 0) *value = ptr->record; @@ -722,7 +722,7 @@ st_delete_safe(register st_table *table, https://github.com/ruby/ruby/blob/trunk/st.c#L722 ptr = table->bins[hash_pos(hash_val, table->num_bins)]; for (; ptr != 0; ptr = ptr->next) { - if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) { + if ((ptr->key != never) && EQUAL(table, *key, ptr)) { remove_entry(table, ptr); *key = ptr->key; if (value != 0) *value = ptr->record; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/