Refactor: Make cmConditionEvaluator::IsTrue a bit more compact

Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
This commit is contained in:
Alex Turbov
2021-07-26 01:54:24 +03:00
committed by Brad King
parent 18bd6c98ea
commit b0d6596399

View File

@@ -149,25 +149,19 @@ bool cmConditionEvaluator::IsTrue(
// now loop through the arguments and see if we can reduce any of them
// we do this multiple times. Once for each level of precedence
// parens
if (!this->HandleLevel0(newArgs, errorString, status)) {
return false;
}
// predicates
if (!this->HandleLevel1(newArgs, errorString, status)) {
return false;
}
// binary ops
if (!this->HandleLevel2(newArgs, errorString, status)) {
return false;
}
// NOT
if (!this->HandleLevel3(newArgs, errorString, status)) {
return false;
}
// AND OR
if (!this->HandleLevel4(newArgs, errorString, status)) {
return false;
using handlerFn_t = bool (cmConditionEvaluator::*)(
cmArgumentList&, std::string&, MessageType&);
const std::array<handlerFn_t, 5> handlers = { {
&cmConditionEvaluator::HandleLevel0, // parenthesis
&cmConditionEvaluator::HandleLevel1, // predicates
&cmConditionEvaluator::HandleLevel2, // binary ops
&cmConditionEvaluator::HandleLevel3, // NOT
&cmConditionEvaluator::HandleLevel4 // AND OR
} };
for (auto fn : handlers) {
if (!(this->*fn)(newArgs, errorString, status)) {
return false;
}
}
// now at the end there should only be one argument left