Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Yip <miloyip@gmail.com>2014-11-23 11:45:07 +0300
committerMilo Yip <miloyip@gmail.com>2014-11-23 11:45:07 +0300
commitb855c3f73a63b60387e37361b65ee531e0384465 (patch)
treee9f9191b330caabf32c95b00832acb30de4c6f2e /include
parent3679c280dd989c583de58126dba2b52341b17317 (diff)
Minor optimization of strtod
Diffstat (limited to 'include')
-rw-r--r--include/rapidjson/internal/diyfp.h16
-rw-r--r--include/rapidjson/internal/strtod.h3
2 files changed, 4 insertions, 15 deletions
diff --git a/include/rapidjson/internal/diyfp.h b/include/rapidjson/internal/diyfp.h
index e6937ecd..a8e47e17 100644
--- a/include/rapidjson/internal/diyfp.h
+++ b/include/rapidjson/internal/diyfp.h
@@ -102,8 +102,8 @@ struct DiyFp {
unsigned long index;
_BitScanReverse64(&index, f);
return DiyFp(f << (63 - index), e - (63 - index));
-#elif 0//defined(__GNUC__)
- int s = __builtin_clzll(f) + 1;
+#elif defined(__GNUC__) && __GNUC__ >= 4
+ int s = __builtin_clzll(f);
return DiyFp(f << s, e - s);
#else
DiyFp res = *this;
@@ -111,22 +111,11 @@ struct DiyFp {
res.f <<= 1;
res.e--;
}
- // while (!(res.f & kDpHiddenBit)) {
- // res.f <<= 1;
- // res.e--;
- // }
- // res.f <<= (kDiySignificandSize - kDpSignificandSize - 1);
- // res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 1);
return res;
#endif
}
DiyFp NormalizeBoundary() const {
-#if defined(_MSC_VER) && defined(_M_AMD64)
- unsigned long index;
- _BitScanReverse64(&index, f);
- return DiyFp (f << (63 - index), e - (63 - index));
-#else
DiyFp res = *this;
while (!(res.f & (kDpHiddenBit << 1))) {
res.f <<= 1;
@@ -135,7 +124,6 @@ struct DiyFp {
res.f <<= (kDiySignificandSize - kDpSignificandSize - 2);
res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 2);
return res;
-#endif
}
void NormalizedBoundaries(DiyFp* minus, DiyFp* plus) const {
diff --git a/include/rapidjson/internal/strtod.h b/include/rapidjson/internal/strtod.h
index ee347665..9a4daeae 100644
--- a/include/rapidjson/internal/strtod.h
+++ b/include/rapidjson/internal/strtod.h
@@ -179,7 +179,8 @@ inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosit
DiyFp(RAPIDJSON_UINT64_C2(0xf4240000, 00000000), -44), // 10^6
DiyFp(RAPIDJSON_UINT64_C2(0x98968000, 00000000), -40) // 10^7
};
- int adjustment = dExp - actualExp - 1;
+ int adjustment = dExp - actualExp - 1;
+ RAPIDJSON_ASSERT(adjustment >= 0 && adjustment < 7);
v = v * kPow10[adjustment];
if (length + adjustment > 19) // has more digits than decimal digits in 64-bit
error += kUlp / 2;