diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-01-04 12:12:57 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-01-05 14:47:37 +0100 |
commit | 87ef16d3c1de7f6eb2b9ec4883e0ae62771c9a63 (patch) | |
tree | fd4e52c9c6eba0f549889aec01098e5abe9b002d /source/fitz/printf.c | |
parent | cd2f3892277db2041ee00cedbd6bff9a5e0dd461 (diff) | |
download | mupdf-87ef16d3c1de7f6eb2b9ec4883e0ae62771c9a63.tar.xz |
Change fz_ftoa to fz_grisu to remove one extra layer of function calls.
Diffstat (limited to 'source/fitz/printf.c')
-rw-r--r-- | source/fitz/printf.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/fitz/printf.c b/source/fitz/printf.c index dcc89952..baa1aa3a 100644 --- a/source/fitz/printf.c +++ b/source/fitz/printf.c @@ -23,17 +23,23 @@ static void fmtputc(struct fmtbuf *out, int c) static void fmtfloat(struct fmtbuf *out, float f) { char digits[40], *s = digits; - int exp, neg, ndigits, point; + int exp, ndigits, point; if (isnan(f)) f = 0; if (isinf(f)) f = f < 0 ? -FLT_MAX : FLT_MAX; - fz_ftoa(f, digits, &exp, &neg, &ndigits); - point = exp + ndigits; - - if (neg) + if (signbit(f)) fmtputc(out, '-'); + if (f == 0) + { + fmtputc(out, '0'); + return; + } + + ndigits = fz_grisu(f, digits, &exp); + point = exp + ndigits; + if (point <= 0) { fmtputc(out, '.'); |