[Pkg-voip-commits] [libre] 08/21: json: improved performance for mypower10 (#88)
Jonas Smedegaard
dr at jones.dk
Sat Dec 2 22:41:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/0.5.6-1
in repository libre.
commit f8b24b462dc9cf95242d450d82e7fadbf4b0d0fd
Author: Alfred E. Heggestad <alfred.heggestad at gmail.com>
Date: Thu Oct 19 14:05:08 2017 +0200
json: improved performance for mypower10 (#88)
---
src/json/decode.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/json/decode.c b/src/json/decode.c
index cf1e9b5..067ecff 100644
--- a/src/json/decode.c
+++ b/src/json/decode.c
@@ -13,12 +13,17 @@
#include <re_json.h>
-static inline uint64_t mypower10(uint64_t e)
+static inline long double mypower10(uint64_t e)
{
- uint64_t i, n = 1;
+ long double p = 10, n = 1;
- for (i=0; i<e; i++)
- n *= 10;
+ while (e > 0) {
+ if (e & 1)
+ n *= p;
+
+ p *= p;
+ e >>= 1;
+ }
return n;
}
@@ -94,7 +99,7 @@ static bool is_number(long double *d, bool *isfloat, const struct pl *pl)
}
}
- *isfloat = (frac || (exp && e < 0));
+ *isfloat = (frac || exp);
if (exp) {
if (e < 0)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/libre.git
More information about the Pkg-voip-commits
mailing list