updated hash function
@@ -1389,12 +1389,13 @@ int
hash(
int key
) {
- key = ~key + (key << 15); /* key = (key << 15) - key - 1; */
- key = key ^ (key >> 12);
- key = key + (key << 2);
- key = key ^ (key >> 4);
- key = key * 2057;
- key = key ^ (key >> 16);
+ int hash = 0;
+ int i;
+
+ for (i = 0; i < sizeof(int); i++) {
+ hash += *(&key + i);
+ }
+
return key;
}
@@ -1403,7 +1404,6 @@ key_bytes_to_int(
ion_byte_t *key,
linear_hash_table_t *linear_hash
) {
-
int i;
int key_bytes_as_int = 0;
@@ -1411,7 +1411,7 @@ key_bytes_to_int(
key_bytes_as_int += *(key + i);
}
- return key_bytes_as_int;
+ return hash(key_bytes_as_int);
}
int
@@ -1422,7 +1422,7 @@ hash_to_bucket(
/* Case the record we are looking for was in a bucket that has already been split and h1 was used */
int key_bytes_as_int = key_bytes_to_int(key, linear_hash);
- return key_bytes_as_int & ((2 * linear_hash->initial_size) - 1);
+ return hash(key_bytes_as_int & ((2 * linear_hash->initial_size) - 1));
}
int
