diff options
author | Björn-Egil Dahlberg <[email protected]> | 2013-10-01 19:27:54 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-01-28 15:56:26 +0100 |
commit | 92303a2e1abdf74aa3bc3af095131a59a601c45e (patch) | |
tree | 0d24f6cd9717659942463e9055f488d77678e673 | |
parent | 03d5bb0d1bd5d7c4e09ee793a680f2d538fe0122 (diff) | |
download | otp-92303a2e1abdf74aa3bc3af095131a59a601c45e.tar.gz otp-92303a2e1abdf74aa3bc3af095131a59a601c45e.tar.bz2 otp-92303a2e1abdf74aa3bc3af095131a59a601c45e.zip |
erts: Add phash2 Map functionality
-rw-r--r-- | erts/emulator/beam/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 6cdfd1c989..bc7e91295d 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -1088,6 +1088,7 @@ make_hash2(Eterm term) #define HCONST_13 0x08d12e65UL #define HCONST_14 0xa708a81eUL #define HCONST_15 0x454021d7UL +#define HCONST_16 0xe3779b90UL #define UINT32_HASH_2(Expr1, Expr2, AConst) \ do { \ @@ -1190,6 +1191,28 @@ make_hash2(Eterm term) term = elem[1]; } break; + case MAP_SUBTAG: + { + map_t *mp = (map_t *)map_val(term); + int i; + int size = map_get_size(mp); + Eterm *ks = map_get_keys(mp); + Eterm *vs = map_get_values(mp); + UINT32_HASH(size, HCONST_16); + if (size == 0) /* Empty Map */ + goto hash2_common; + + for (i = size - 1; i >= 0; i--) { + tmp = vs[i]; + ESTACK_PUSH(s, tmp); + } + for (i = size - 1; i >= 1; i--) { + tmp = ks[i]; + ESTACK_PUSH(s, tmp); + } + term = ks[0]; + } + break; case EXPORT_SUBTAG: { Export* ep = *((Export **) (export_val(term) + 1)); |