File 2077-Optimize-performance-of-float_to_list-2.patch of Package erlang

From 540ab1efe49a1bfbcb47136e8ba553524ac55686 Mon Sep 17 00:00:00 2001
From: Serge Aleynikov <saleyn@gmail.com>
Date: Thu, 19 Apr 2018 10:56:52 -0400
Subject: [PATCH] Optimize performance of float_to_list/2

---
 erts/emulator/sys/common/erl_sys_common_misc.c | 13 ++++++++-----
 1 file 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++ = '-';
-- 
2.16.3

openSUSE Build Service is sponsored by