[clang-tidy] Simplify boolean expressions
Found with readability-simplify-boolean-expr Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
committed by
Paul Beckingham
parent
13e1bf7204
commit
51870dff34
@@ -1820,7 +1820,7 @@ void Variant::cast (const enum type new_type)
|
||||
case type_integer:
|
||||
switch (new_type)
|
||||
{
|
||||
case type_boolean: _bool = _integer == 0 ? false : true; break;
|
||||
case type_boolean: _bool = _integer != 0; break;
|
||||
case type_integer: break;
|
||||
case type_real: _real = static_cast<double>(_integer); break;
|
||||
case type_string:
|
||||
@@ -1838,7 +1838,7 @@ void Variant::cast (const enum type new_type)
|
||||
case type_real:
|
||||
switch (new_type)
|
||||
{
|
||||
case type_boolean: _bool = _real == 0.0 ? false : true; break;
|
||||
case type_boolean: _bool = _real != 0.0; break;
|
||||
case type_integer: _integer = static_cast<int>(_real); break;
|
||||
case type_real: break;
|
||||
case type_string:
|
||||
@@ -1858,9 +1858,9 @@ void Variant::cast (const enum type new_type)
|
||||
switch (new_type)
|
||||
{
|
||||
case type_boolean:
|
||||
_bool = (_string.length () == 0 ||
|
||||
_bool = !(_string.length () == 0 ||
|
||||
_string == "0" ||
|
||||
_string == "0.0") ? false : true;
|
||||
_string == "0.0");
|
||||
break;
|
||||
case type_integer:
|
||||
_integer = static_cast<int>(strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10)));
|
||||
@@ -1913,7 +1913,7 @@ void Variant::cast (const enum type new_type)
|
||||
case type_date:
|
||||
switch (new_type)
|
||||
{
|
||||
case type_boolean: _bool = _date != 0 ? true : false; break;
|
||||
case type_boolean: _bool = _date != 0; break;
|
||||
case type_integer: _integer = static_cast<int>(_date); break;
|
||||
case type_real: _real = static_cast<double>(_date); break;
|
||||
case type_string: _string = std::string(*this); break;
|
||||
@@ -1925,7 +1925,7 @@ void Variant::cast (const enum type new_type)
|
||||
case type_duration:
|
||||
switch (new_type)
|
||||
{
|
||||
case type_boolean: _bool = _duration != 0 ? true : false; break;
|
||||
case type_boolean: _bool = _duration != 0; break;
|
||||
case type_integer: _integer = static_cast<int>(_duration); break;
|
||||
case type_real: _real = static_cast<double>(_duration); break;
|
||||
case type_string: _string = std::string(*this); break;
|
||||
|
||||
Reference in New Issue
Block a user