aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/bif.c
diff options
context:
space:
mode:
authorGuilherme Andrade <[email protected]>2017-04-20 21:35:54 +0100
committerGuilherme Andrade <[email protected]>2017-04-20 21:51:16 +0100
commit1b37d0b010ea31b04b9d0a15d0bec9c75a013dc9 (patch)
treea543b013c074d8e763a31e0adf706f7cf922176a /erts/emulator/beam/bif.c
parent0835f40ae25f97360dc393928796387d3cd6b16e (diff)
downloadotp-1b37d0b010ea31b04b9d0a15d0bec9c75a013dc9.tar.gz
otp-1b37d0b010ea31b04b9d0a15d0bec9c75a013dc9.tar.bz2
otp-1b37d0b010ea31b04b9d0a15d0bec9c75a013dc9.zip
erts: Remove enif_phash2_ranged
Diffstat (limited to 'erts/emulator/beam/bif.c')
-rw-r--r--erts/emulator/beam/bif.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index d59adc18d6..214de3652f 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -4888,6 +4888,7 @@ BIF_RETTYPE phash2_1(BIF_ALIST_1)
BIF_RETTYPE phash2_2(BIF_ALIST_2)
{
Uint32 hash;
+ Uint32 final_hash;
Uint32 range;
/* Check for special case 2^32 */
@@ -4900,19 +4901,23 @@ BIF_RETTYPE phash2_2(BIF_ALIST_2)
}
range = (Uint32) u;
}
- hash = make_hash2_within_range(BIF_ARG_1, range);
-
+ hash = make_hash2(BIF_ARG_1);
+ if (range) {
+ final_hash = hash % range; /* [0..range-1] */
+ } else {
+ final_hash = hash;
+ }
/*
* Return either a small or a big. Use the heap for bigs if there is room.
*/
#if defined(ARCH_64)
- BIF_RET(make_small(hash));
+ BIF_RET(make_small(final_hash));
#else
- if (IS_USMALL(0, hash)) {
- BIF_RET(make_small(hash));
+ if (IS_USMALL(0, final_hash)) {
+ BIF_RET(make_small(final_hash));
} else {
Eterm* hp = HAlloc(BIF_P, BIG_UINT_HEAP_SIZE);
- BIF_RET(uint_to_big(hash, hp));
+ BIF_RET(uint_to_big(final_hash, hp));
}
#endif
}