diff options
author | Sverker Eriksson <[email protected]> | 2018-04-20 16:36:42 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2018-04-20 16:36:42 +0200 |
commit | 98cd99ef1eaf32822404daced985258ac4973e14 (patch) | |
tree | 1bc50a5ae2d02be8812dda049e933114b899e705 /erts | |
parent | e4fb2f14cbdfdf34e6604618136aef66d9db0190 (diff) | |
parent | 540ab1efe49a1bfbcb47136e8ba553524ac55686 (diff) | |
download | otp-98cd99ef1eaf32822404daced985258ac4973e14.tar.gz otp-98cd99ef1eaf32822404daced985258ac4973e14.tar.bz2 otp-98cd99ef1eaf32822404daced985258ac4973e14.zip |
Merge PR-1792 from saleyn/float_to_list
Optimize performance of float_to_list/2
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/sys/common/erl_sys_common_misc.c | 13 |
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++ = '-'; |