json: improved performance for mypower10 (#88)
This commit is contained in:
parent
03841f546b
commit
f8b24b462d
1 changed files with 10 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue