summaryrefslogtreecommitdiffstats
path: root/Source/cmConditionEvaluator.cxx
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2021-07-25 22:54:24 (GMT)
committerBrad King <brad.king@kitware.com>2021-08-03 14:55:30 (GMT)
commitb0d65963992d85349487a3fdf51cfced6910384d (patch)
tree645bcbc5a15db1dc0e43296ed1fbc31c996d26b3 /Source/cmConditionEvaluator.cxx
parent18bd6c98ea70adf3067539266fdb782e910fb3cc (diff)
downloadCMake-b0d65963992d85349487a3fdf51cfced6910384d.zip
CMake-b0d65963992d85349487a3fdf51cfced6910384d.tar.gz
CMake-b0d65963992d85349487a3fdf51cfced6910384d.tar.bz2
Refactor: Make `cmConditionEvaluator::IsTrue` a bit more compact
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
Diffstat (limited to 'Source/cmConditionEvaluator.cxx')
-rw-r--r--Source/cmConditionEvaluator.cxx32
1 files changed, 13 insertions, 19 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 99927d7..7ea0daf 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -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