diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2021-07-27 15:36:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-08-03 14:55:46 (GMT) |
commit | 51d9194a96df4cb8cd144afce4edc6e2122fab2d (patch) | |
tree | 9cb3d475781659104c0a8a2b373bb8c76b3623b6 /Source/cmConditionEvaluator.cxx | |
parent | 46810235e3a8420b3379b352dd6b19d7a0439acd (diff) | |
download | CMake-51d9194a96df4cb8cd144afce4edc6e2122fab2d.zip CMake-51d9194a96df4cb8cd144afce4edc6e2122fab2d.tar.gz CMake-51d9194a96df4cb8cd144afce4edc6e2122fab2d.tar.bz2 |
Refactor: Reduce one more condition checking on handling math compare
Diffstat (limited to 'Source/cmConditionEvaluator.cxx')
-rw-r--r-- | Source/cmConditionEvaluator.cxx | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 570bb4a..8224121 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -619,18 +619,18 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, double lhs; double rhs; - bool result; - if (std::sscanf(ldef->c_str(), "%lg", &lhs) != 1 || - std::sscanf(rdef->c_str(), "%lg", &rhs) != 1) { - result = false; - } else { + auto parseDoubles = [&]() { + return std::sscanf(ldef->c_str(), "%lg", &lhs) == 1 && + std::sscanf(rdef->c_str(), "%lg", &rhs) == 1; + }; + const auto result = parseDoubles() && // clang-format off - result = cmRt2CtSelector< - std::less, std::less_equal, std::greater, - std::greater_equal, std::equal_to + cmRt2CtSelector< + std::less, std::less_equal, + std::greater, std::greater_equal, + std::equal_to >::eval(matchNo, lhs, rhs); - // clang-format on - } + // clang-format on HandleBinaryOp(result, newArgs, arg, argP1, argP2); } @@ -643,8 +643,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, const auto val = (*lhs).compare(*rhs); // clang-format off const auto result = cmRt2CtSelector< - std::less, std::less_equal, std::greater, - std::greater_equal, std::equal_to + std::less, std::less_equal, + std::greater, std::greater_equal, + std::equal_to >::eval(matchNo, val, 0); // clang-format on HandleBinaryOp(result, newArgs, arg, argP1, argP2); |