[前][次][番号順一覧][スレッド一覧]

ruby-changes:22272

From: nobu <ko1@a...>
Date: Tue, 17 Jan 2012 10:55:01 +0900 (JST)
Subject: [ruby-changes:22272] nobu:r34321 (trunk): * st.c (do_hash): it's the time to remove cast to unsigned int.

nobu	2012-01-17 10:54:50 +0900 (Tue, 17 Jan 2012)

  New Revision: 34321

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34321

  Log:
    * st.c (do_hash): it's the time to remove cast to unsigned int.

  Modified files:
    trunk/ChangeLog
    trunk/st.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34320)
+++ ChangeLog	(revision 34321)
@@ -1,3 +1,7 @@
+Tue Jan 17 10:54:46 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* st.c (do_hash): it's the time to remove cast to unsigned int.
+
 Tue Jan 17 07:30:12 2012  NARUSE, Yui  <naruse@r...>
 
 	* st.c (unpack_entries): Fix r34310: on unpacking, the position of
Index: st.c
===================================================================
--- st.c	(revision 34320)
+++ st.c	(revision 34321)
@@ -72,8 +72,7 @@
 
 #define EQUAL(table,x,y) ((x)==(y) || (*(table)->type->compare)((x),(y)) == 0)
 
-/* remove cast to unsigned int in the future */
-#define do_hash(key,table) (unsigned int)(st_index_t)(*(table)->type->hash)((key))
+#define do_hash(key,table) (st_index_t)(*(table)->type->hash)((key))
 #define do_hash_bin(key,table) (do_hash((key), (table))%(table)->num_bins)
 
 /* preparation for possible allocation improvements */
@@ -462,9 +461,9 @@
     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 = 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);
+	/* packed table should be numhash */
+	st_index_t key = PKEY(table, i), value = PVAL(table, i);
+	add_direct(&tmp_table, key, value, key, key % tmp_table.num_bins);
     }
     *table = tmp_table;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]