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:
authormiloyip <miloyip@gmail.com>2014-09-03 10:45:37 +0400
committermiloyip <miloyip@gmail.com>2014-09-03 10:45:37 +0400
commitb0436911a8ce2b7e2aa73972d5275702a60cc3ae (patch)
tree6318e6f1375f865f3cbe85bcecbc6d4f8be839ff /include/rapidjson
parent818f6f1f2e7158369a2d2029b6962764ab70c22a (diff)
Check "fast path cases in disguise" in strtod
Diffstat (limited to 'include/rapidjson')
-rw-r--r--include/rapidjson/reader.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h
index 0615ce2d..92deeab7 100644
--- a/include/rapidjson/reader.h
+++ b/include/rapidjson/reader.h
@@ -877,11 +877,21 @@ private:
if (useDouble) {
int p = exp + expFrac;
double d;
- uint64_t significand = use64bit ? i64 : i;
+ double significand = use64bit ? i64 : i;
// Use fast path for string-to-double conversion if possible
// see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion/
- if (!useStrtod && p >= -22 && p <= 22 && significand <= RAPIDJSON_UINT64_C2(0x001FFFFF, 0xFFFFFFFF)) {
+ if (!useStrtod && p > 22) {
+ if (p < 22 + 16) {
+ // Fast Path Cases In Disguise
+ significand *= internal::Pow10(p - 22);
+ p = 22;
+ }
+ else
+ useStrtod = true;
+ }
+
+ if (!useStrtod && p >= -22 && significand <= 9007199254740991.0) { // 2^53 - 1
if (p >= 0)
d = significand * internal::Pow10(p);
else