summaryrefslogtreecommitdiffstats
path: root/src/web_buffer.c
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2015-03-20 00:41:46 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2015-03-20 00:41:46 +0200
commitb57ec553cbbfa2fb4796e86054acb1b2aa95e3e6 (patch)
tree48c12462557870481d942b1cc67040d63288798b /src/web_buffer.c
parent5c22120e41d654ebfc8ae0adb2aa29fb84959253 (diff)
80% speed increase in number printing on 32bit systems
Diffstat (limited to 'src/web_buffer.c')
-rwxr-xr-xsrc/web_buffer.c56
1 files changed, 0 insertions, 56 deletions
diff --git a/src/web_buffer.c b/src/web_buffer.c
index 7c57ce8c6a..d9eb11d54b 100755
--- a/src/web_buffer.c
+++ b/src/web_buffer.c
@@ -20,62 +20,6 @@ void web_buffer_strcpy(struct web_buffer *wb, const char *txt)
wb->bytes = bytes;
}
-int print_calculated_number(char *str, calculated_number value)
-{
- char *wstr = str;
-
- int sign = (value < 0) ? 1 : 0;
- if(sign) value = -value;
-
-#ifdef STORAGE_WITH_MATH
- // without llrint() there are rounding problems
- // for example 0.9 becomes 0.89
- unsigned long long uvalue = llrint(value * (calculated_number)100000);
-#else
- unsigned long long uvalue = value * (calculated_number)100000;
-#endif
-
- // print each digit
- do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
-
- // make sure we have 6 bytes at least
- while((wstr - str) < 6) *wstr++ = '0';
-
- // put the sign back
- if(sign) *wstr++ = '-';
-
- // reverse it
- char *begin = str, *end = --wstr, aux;
- while (end > begin) aux = *end, *end-- = *begin, *begin++ = aux;
- // wstr--;
- // strreverse(str, wstr);
-
- // remove trailing zeros
- int decimal = 5;
- while(decimal > 0 && *wstr == '0') {
- *wstr-- = '\0';
- decimal--;
- }
-
- // terminate it, one position to the right
- // to let space for a dot
- wstr[2] = '\0';
-
- // make space for the dot
- int i;
- for(i = 0; i < decimal ;i++) {
- wstr[1] = wstr[0];
- wstr--;
- }
-
- // put the dot
- if(wstr[2] == '\0') { wstr[1] = '\0'; decimal--; }
- else wstr[1] = '.';
-
- // return the buffer length
- return ( (wstr - str) + 2 + decimal );
-}
-
void web_buffer_rrd_value(struct web_buffer *wb, calculated_number value)
{
if(wb->size - wb->bytes < 50) return;