JSON: Fix MSVC2013 warnings

json.cpp(221) : warning C4800: 'uint64_t' : forcing value to bool 'true' or 'false' (performance warning)
json.cpp(322) : warning C4800: 'uint32_t' : forcing value to bool 'true' or 'false' (performance warning)
json.cpp(756) : warning C4244: '=' : conversion from 'int64_t' to 'double', possible loss of data
json.cpp(953) : warning C4244: 'return' : conversion from 'const double' to 'int', possible loss of data
json.cpp(4408) : warning C4244: 'argument' : conversion from '__int64' to 'int', possible loss of data

Change-Id: I2a24f90f7615aeb47f747ecbe3b580f23773ebda
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-11-11 10:29:50 +02:00
committed by Orgad Shaneh
parent 0f9e2baa1b
commit 942aa12f77

View File

@@ -218,7 +218,7 @@ static int compressedNumber(double d)
if (non_int) if (non_int)
return INT_MAX; return INT_MAX;
bool neg = (val >> 63); bool neg = (val >> 63) != 0;
val &= fraction_mask; val &= fraction_mask;
val |= ((uint64_t)1 << 52); val |= ((uint64_t)1 << 52);
int res = (int)(val >> (52 - exp)); int res = (int)(val >> (52 - exp));
@@ -319,7 +319,7 @@ public:
offset tableOffset; offset tableOffset;
// content follows here // content follows here
bool isObject() const { return is_object; } bool isObject() const { return !!is_object; }
bool isArray() const { return !isObject(); } bool isArray() const { return !isObject(); }
offset *table() const { return (offset *) (((char *) this) + tableOffset); } offset *table() const { return (offset *) (((char *) this) + tableOffset); }
@@ -753,7 +753,7 @@ JsonValue::JsonValue(int n)
JsonValue::JsonValue(int64_t n) JsonValue::JsonValue(int64_t n)
: d(0), t(Double) : d(0), t(Double)
{ {
this->dbl = n; this->dbl = double(n);
} }
/*! /*!
@@ -950,7 +950,7 @@ bool JsonValue::toBool(bool defaultValue) const
int JsonValue::toInt(int defaultValue) const int JsonValue::toInt(int defaultValue) const
{ {
if (t == Double && int(dbl) == dbl) if (t == Double && int(dbl) == dbl)
return dbl; return int(dbl);
return defaultValue; return defaultValue;
} }
@@ -4405,7 +4405,7 @@ bool Parser::parseNumber(Value *val, int baseOffset)
char *endptr = const_cast<char *>(json); char *endptr = const_cast<char *>(json);
long long int n = strtoll(start, &endptr, 0); long long int n = strtoll(start, &endptr, 0);
if (endptr != start && n < (1<<25) && n > -(1<<25)) { if (endptr != start && n < (1<<25) && n > -(1<<25)) {
val->int_value = n; val->int_value = int(n);
val->intValue = true; val->intValue = true;
END; END;
return true; return true;