Remove unneeded iostream include
[folly.git] / folly / json.cpp
index 86600fd5d7ca21d011136b1e87fa498aaede8d95..105b1ca7ff9264574fdd1ee0c9fb024ece10fa0b 100644 (file)
@@ -512,9 +512,9 @@ dynamic parseNumber(Input& in) {
   auto const wasE = *in == 'e' || *in == 'E';
 
   constexpr const char* maxInt = "9223372036854775807";
-  constexpr const char* minInt = "9223372036854775808";
+  constexpr const char* minInt = "-9223372036854775808";
   constexpr auto maxIntLen = constexpr_strlen(maxInt);
-
+  constexpr auto minIntLen = constexpr_strlen(minInt);
 
   if (*in != '.' && !wasE && in.getOpts().parse_numbers_as_strings) {
     return integral;
@@ -522,8 +522,8 @@ dynamic parseNumber(Input& in) {
 
   if (*in != '.' && !wasE) {
     if (LIKELY(!in.getOpts().double_fallback || integral.size() < maxIntLen) ||
-         (integral.size() == maxIntLen &&
-           (integral <= maxInt || (integral == minInt && negative)))) {
+        (!negative && integral.size() == maxIntLen && integral <= maxInt) ||
+        (negative && integral.size() == minIntLen && integral <= minInt)) {
       auto val = to<int64_t>(integral);
       in.skipWhitespace();
       return val;
@@ -693,7 +693,6 @@ void escapeString(
     return c < 10 ? c + '0' : c - 10 + 'a';
   };
 
-  out.reserve(out.size() + input.size() + 2);
   out.push_back('\"');
 
   auto* p = reinterpret_cast<const unsigned char*>(input.begin());