aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/bif.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/beam/bif.c')
-rw-r--r--erts/emulator/beam/bif.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 214de3652f..d59adc18d6 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -4888,7 +4888,6 @@ 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 */
@@ -4901,23 +4900,19 @@ BIF_RETTYPE phash2_2(BIF_ALIST_2)
}
range = (Uint32) u;
}
- hash = make_hash2(BIF_ARG_1);
- if (range) {
- final_hash = hash % range; /* [0..range-1] */
- } else {
- final_hash = hash;
- }
+ hash = make_hash2_within_range(BIF_ARG_1, range);
+
/*
* Return either a small or a big. Use the heap for bigs if there is room.
*/
#if defined(ARCH_64)
- BIF_RET(make_small(final_hash));
+ BIF_RET(make_small(hash));
#else
- if (IS_USMALL(0, final_hash)) {
- BIF_RET(make_small(final_hash));
+ if (IS_USMALL(0, hash)) {
+ BIF_RET(make_small(hash));
} else {
Eterm* hp = HAlloc(BIF_P, BIG_UINT_HEAP_SIZE);
- BIF_RET(uint_to_big(final_hash, hp));
+ BIF_RET(uint_to_big(hash, hp));
}
#endif
}