aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorSerge Aleynikov <[email protected]>2018-04-19 10:56:52 -0400
committerSerge Aleynikov <[email protected]>2018-04-19 11:13:51 -0400
commit540ab1efe49a1bfbcb47136e8ba553524ac55686 (patch)
tree36870308869c1b5f97689d83b79bd5bf98ecd512 /erts
parent0bcba3f1c9afc9a4164bf78641844a293768a7ec (diff)
downloadotp-540ab1efe49a1bfbcb47136e8ba553524ac55686.tar.gz
otp-540ab1efe49a1bfbcb47136e8ba553524ac55686.tar.bz2
otp-540ab1efe49a1bfbcb47136e8ba553524ac55686.zip
Optimize performance of float_to_list/2
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/sys/common/erl_sys_common_misc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/erts/emulator/sys/common/erl_sys_common_misc.c b/erts/emulator/sys/common/erl_sys_common_misc.c
index 826307c077..41a6fcb7e1 100644
--- a/erts/emulator/sys/common/erl_sys_common_misc.c
+++ b/erts/emulator/sys/common/erl_sys_common_misc.c
@@ -217,14 +217,16 @@ sys_double_to_chars_fast(double f, char *buffer, int buffer_size, int decimals,
}
do {
+ Uint64 n;
if (!frac_part) {
do {
*p++ = '0';
} while (--decimals);
break;
}
- *p++ = (char)((frac_part % 10) + '0');
- frac_part /= 10;
+ n = frac_part / 10;
+ *p++ = (char)((frac_part - n*10) + '0');
+ frac_part = n;
} while (--decimals);
*p++ = '.';
@@ -236,9 +238,10 @@ sys_double_to_chars_fast(double f, char *buffer, int buffer_size, int decimals,
*p++ = '0';
} else {
do {
- *p++ = (char)((int_part % 10) + '0');
- int_part /= 10;
- }while (int_part);
+ Uint64 n = int_part / 10;
+ *p++ = (char)((int_part - n*10) + '0');
+ int_part = n;
+ } while (int_part);
}
if (neg)
*p++ = '-';