From b47a8245774ee1d57872d99015081e6307e037f1 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Wed, 27 Jul 2011 16:41:13 +0200 Subject: Optimise bugnum and small comparison As it is possible to assume that bignums are bigger than smalls, we can just check the sign of the bignum. --- erts/emulator/beam/utils.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'erts/emulator/beam') diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index e67a793b9a..5e22aa42c8 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -2657,8 +2657,10 @@ tailrecur_ne: switch(_NUMBER_CODE(a_tag, b_tag)) { case SMALL_BIG: - big = small_to_big(signed_val(a), big_buf); - j = big_comp(big, bw); + j = big_sign(bw) ? 1 : -1; + break; + case BIG_SMALL: + j = big_sign(aw) ? -1 : 1; break; case SMALL_FLOAT: GET_DOUBLE(bw, f2); @@ -2674,10 +2676,6 @@ tailrecur_ne: j = signed_val(a) - (Sint) f2.fd; } break; - case BIG_SMALL: - big = small_to_big(signed_val(b), big_buf); - j = big_comp(aw, big); - break; case BIG_FLOAT: GET_DOUBLE(bw, f2); if ((f2.fd < 9007199254740990.0 && f2.fd > -9007199254740990.0)) { -- cgit v1.2.3