mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 18:10:27 +01:00
Optimize value range check
This commit is contained in:
parent
12e9ef32f9
commit
b4abc8241f
@ -1279,7 +1279,11 @@ bool Value::isBool() const { return type_ == booleanValue; }
|
||||
bool Value::isInt() const {
|
||||
switch (type_) {
|
||||
case intValue:
|
||||
#if defined(JSON_HAS_INT64)
|
||||
return value_.int_ >= minInt && value_.int_ <= maxInt;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
case uintValue:
|
||||
return value_.uint_ <= UInt(maxInt);
|
||||
case realValue:
|
||||
@ -1294,9 +1298,17 @@ bool Value::isInt() const {
|
||||
bool Value::isUInt() const {
|
||||
switch (type_) {
|
||||
case intValue:
|
||||
#if defined(JSON_HAS_INT64)
|
||||
return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
|
||||
#else
|
||||
return value_.int_ >= 0;
|
||||
#endif
|
||||
case uintValue:
|
||||
#if defined(JSON_HAS_INT64)
|
||||
return value_.uint_ <= maxUInt;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
case realValue:
|
||||
return value_.real_ >= 0 && value_.real_ <= maxUInt &&
|
||||
IsIntegral(value_.real_);
|
||||
|
Loading…
Reference in New Issue
Block a user