Minor cleanups

This commit is contained in:
Nyall Dawson 2025-06-11 09:48:34 +10:00
parent a2e1098224
commit 51af543fd7

View File

@ -270,25 +270,43 @@ QVariant QgsExpressionNodeBinaryOperator::compareNonNullValues( QgsExpression *p
// All other variants always return false. // All other variants always return false.
// Note: Boolean logical operators behave the same in C++ and SQL. // Note: Boolean logical operators behave the same in C++ and SQL.
switch ( mOp ) const bool vLBool = vL.toBool();
const bool vRBool = vR.toBool();
switch ( op )
{ {
case boEQ: case boEQ:
return vL.toBool() == vR.toBool() ? TVL_True : TVL_False; return vLBool == vRBool ? TVL_True : TVL_False;
case boNE: case boNE:
return vL.toBool() != vR.toBool() ? TVL_True : TVL_False; return vLBool != vRBool ? TVL_True : TVL_False;
case boLT: case boLT:
return vL.toBool() < vR.toBool() ? TVL_True : TVL_False; return vLBool < vRBool ? TVL_True : TVL_False;
case boLE: case boLE:
return vL.toBool() <= vR.toBool() ? TVL_True : TVL_False; return vLBool <= vRBool ? TVL_True : TVL_False;
case boGT: case boGT:
return vL.toBool() > vR.toBool() ? TVL_True : TVL_False; return vLBool > vRBool ? TVL_True : TVL_False;
case boGE: case boGE:
return vL.toBool() >= vR.toBool() ? TVL_True : TVL_False; return vLBool >= vRBool ? TVL_True : TVL_False;
default: case boOr:
// Can't happen [cosmic ray hits excepted] case boAnd:
Q_ASSERT( false ); case boRegexp:
return TVL_Unknown; case boLike:
case boNotLike:
case boILike:
case boNotILike:
case boIs:
case boIsNot:
case boPlus:
case boMinus:
case boMul:
case boDiv:
case boIntDiv:
case boMod:
case boPow:
case boConcat:
// should not happen
break;
} }
return TVL_Unknown;
} }
// warning - QgsExpression::isIntervalSafe is VERY expensive and should not be used here // warning - QgsExpression::isIntervalSafe is VERY expensive and should not be used here