aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-02-13 19:45:45 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-12 19:15:24 +0100
commit04237c0948fdaba9af1a50c7fd9c5512afd10bb2 (patch)
tree65ba2aa4220f5ab362432ee8997da71728063809
parent2583604581eb07b9a6962bfc76c5015afca840b5 (diff)
downloadotp-04237c0948fdaba9af1a50c7fd9c5512afd10bb2.tar.gz
otp-04237c0948fdaba9af1a50c7fd9c5512afd10bb2.tar.bz2
otp-04237c0948fdaba9af1a50c7fd9c5512afd10bb2.zip
erts: Make hashmap use the new hash function
-rw-r--r--erts/emulator/beam/erl_hashmap.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/erts/emulator/beam/erl_hashmap.c b/erts/emulator/beam/erl_hashmap.c
index b423111715..583ff52c26 100644
--- a/erts/emulator/beam/erl_hashmap.c
+++ b/erts/emulator/beam/erl_hashmap.c
@@ -48,10 +48,12 @@
#define DECL_AM(S) Eterm AM_ ## S = am_atom_put(#S, sizeof(#S) - 1)
#endif
+#define hashmap_make_hash(Key) make_hash_vsn(Key, 3)
+
#define hashmap_restore_hash(Heap,Lvl,Key) \
- ((Lvl) < 8) ? make_hash2(Key) >> (4*(Lvl)) : make_hash2(CONS(Heap, make_small(Lvl), (Key))) >> (4*((Lvl) & 7))
+ ((Lvl) < 8) ? hashmap_make_hash(Key) >> (4*(Lvl)) : hashmap_make_hash(CONS(Heap, make_small(Lvl), (Key))) >> (4*((Lvl) & 7))
#define hashmap_shift_hash(Heap,Hx,Lvl,Key) \
- ((++(Lvl)) & 7) ? (Hx) >> 4 : make_hash2(CONS(Heap, make_small(Lvl), Key))
+ ((++(Lvl)) & 7) ? (Hx) >> 4 : hashmap_make_hash(CONS(Heap, make_small(Lvl), Key))
#if 0
static char *format_binary(Uint64 x, char *b) {
@@ -93,7 +95,7 @@ BIF_RETTYPE hashmap_new_0(BIF_ALIST_0) {
BIF_RETTYPE hashmap_put_3(BIF_ALIST_3) {
if (is_hashmap(BIF_ARG_3)) {
- Uint32 hx = make_hash2(BIF_ARG_1);
+ Uint32 hx = hashmap_make_hash(BIF_ARG_1);
Eterm map;
map = hashmap_insert(BIF_P, hx, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3, 0);
@@ -107,7 +109,7 @@ BIF_RETTYPE hashmap_put_3(BIF_ALIST_3) {
BIF_RETTYPE hashmap_update_3(BIF_ALIST_3) {
if (is_hashmap(BIF_ARG_3)) {
- Uint32 hx = make_hash2(BIF_ARG_1);
+ Uint32 hx = hashmap_make_hash(BIF_ARG_1);
Eterm map;
map = hashmap_insert(BIF_P, hx, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3, 1);
@@ -132,7 +134,7 @@ BIF_RETTYPE hashmap_to_list_1(BIF_ALIST_1) {
BIF_RETTYPE hashmap_get_2(BIF_ALIST_2) {
if (is_hashmap(BIF_ARG_2)) {
const Eterm *value;
- Uint32 hx = make_hash2(BIF_ARG_1);
+ Uint32 hx = hashmap_make_hash(BIF_ARG_1);
if ((value = hashmap_get(hx, BIF_ARG_1, BIF_ARG_2)) != NULL) {
BIF_RET(*value);
@@ -147,7 +149,7 @@ BIF_RETTYPE hashmap_find_2(BIF_ALIST_2) {
if (is_hashmap(BIF_ARG_2)) {
Eterm *hp, res;
const Eterm *value;
- Uint32 hx = make_hash2(BIF_ARG_1);
+ Uint32 hx = hashmap_make_hash(BIF_ARG_1);
if ((value = hashmap_get(hx, BIF_ARG_1, BIF_ARG_2)) != NULL) {
hp = HAlloc(BIF_P, 3);
@@ -167,7 +169,7 @@ BIF_RETTYPE hashmap_find_2(BIF_ALIST_2) {
BIF_RETTYPE hashmap_remove_2(BIF_ALIST_2) {
if (is_hashmap(BIF_ARG_2)) {
- Uint32 hx = make_hash2(BIF_ARG_1);
+ Uint32 hx = hashmap_make_hash(BIF_ARG_1);
BIF_RET(hashmap_delete(BIF_P, hx, BIF_ARG_1, BIF_ARG_2));
}
@@ -204,7 +206,7 @@ BIF_RETTYPE is_hashmap_1(BIF_ALIST_1) {
BIF_RETTYPE hashmap_is_key_2(BIF_ALIST_2) {
if (is_hashmap(BIF_ARG_1)) {
- Uint32 hx = make_hash2(BIF_ARG_1);
+ Uint32 hx = hashmap_make_hash(BIF_ARG_1);
BIF_RET(hashmap_get(hx, BIF_ARG_1, BIF_ARG_2) ? am_true : am_false);
}