diff options
author | Lukas Larsson <[email protected]> | 2011-10-03 19:09:55 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2011-10-11 17:19:01 +0200 |
commit | f82d49ab3e65f52fd7b6dd7d9e8913543b7a1375 (patch) | |
tree | c05558771e1ee9984a437e24b115271b3da7b0b8 /erts/emulator/beam/utils.c | |
parent | 3dc379948b1d7ce6c4f35f56df937603a6013f24 (diff) | |
download | otp-f82d49ab3e65f52fd7b6dd7d9e8913543b7a1375.tar.gz otp-f82d49ab3e65f52fd7b6dd7d9e8913543b7a1375.tar.bz2 otp-f82d49ab3e65f52fd7b6dd7d9e8913543b7a1375.zip |
Do small optimisation on platforms with 32 bit Eterm
On 32 bit we know that a comparison with a lossfull double
and a short will always give the float is being superior.
So therefore we only have to check the sign on the double.
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r-- | erts/emulator/beam/utils.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index f296ccbadd..825cb140b2 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -2670,6 +2670,7 @@ tailrecur_ne: // Float is within the no loss limit f1.fd = signed_val(aw); j = float_comp(f1.fd, f2.fd); +#if ERTS_SIZEOF_ETERM == 8 } else if (f2.fd > (double) (MAX_SMALL + 1)) { // Float is a positive bignum, i.e. bigger j = -1; @@ -2679,6 +2680,12 @@ tailrecur_ne: } else { // Float is a Sint but less precise j = signed_val(aw) - (Sint) f2.fd; } +#else + } else { + // If float is positive it is bigger than small + j = (f2.fd > 0.0) ? -1 : 1; + } +#endif // ERTS_SIZEOF_ETERM == 8 break; case BIG_FLOAT: GET_DOUBLE(bw, f2); @@ -2710,6 +2717,7 @@ tailrecur_ne: // Float is within the no loss limit f2.fd = signed_val(bw); j = float_comp(f1.fd, f2.fd); +#if ERTS_SIZEOF_ETERM == 8 } else if (f1.fd > (double) (MAX_SMALL + 1)) { // Float is a positive bignum, i.e. bigger j = 1; @@ -2719,6 +2727,12 @@ tailrecur_ne: } else { // Float is a Sint but less precise it j = (Sint) f1.fd - signed_val(bw); } +#else + } else { + // If float is positive it is bigger than small + j = (f1.fd > 0.0) ? 1 : -1; + } +#endif // ERTS_SIZEOF_ETERM == 8 break; case FLOAT_BIG: GET_DOUBLE(aw, f1); |