Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
json: improved performance for mypower10 (#88)
  • Loading branch information
alfredh authored and richaas committed Oct 19, 2017
1 parent 03841f5 commit f8b24b4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/json/decode.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f8b24b4

Please sign in to comment.