summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2021-07-25 00:41:26 (GMT)
committerAlex Turbov <i.zaufi@gmail.com>2021-07-26 20:40:18 (GMT)
commit95fc27cedde069c884d151644bf1e7ef105dc7da (patch)
treebf6ebad6b81be4ce18885d9b230118844a89bb51
parent135c37bdd73a8de5a2da43e652f26948481dd936 (diff)
downloadCMake-95fc27cedde069c884d151644bf1e7ef105dc7da.zip
CMake-95fc27cedde069c884d151644bf1e7ef105dc7da.tar.gz
CMake-95fc27cedde069c884d151644bf1e7ef105dc7da.tar.bz2
Refactor: Rewrite parenthesis scanner to avoid `if`s
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
-rw-r--r--Source/cmConditionEvaluator.cxx17
1 files changed, 5 insertions, 12 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index be7ae88..ef05560 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -362,18 +362,11 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
for (auto arg = newArgs.begin(); arg != newArgs.end(); ++arg) {
if (this->IsKeyword(keyParenL, *arg)) {
// search for the closing paren for this opening one
- cmArgumentList::iterator argClose;
- argClose = arg;
- argClose++;
- auto depth = 1u;
- while (argClose != newArgs.end() && depth) {
- if (this->IsKeyword(keyParenL, *argClose)) {
- depth++;
- }
- if (this->IsKeyword(keyParenR, *argClose)) {
- depth--;
- }
- argClose++;
+ auto depth = 1;
+ auto argClose = std::next(arg);
+ for (; argClose != newArgs.end() && depth; ++argClose) {
+ depth += int(this->IsKeyword(keyParenL, *argClose)) -
+ int(this->IsKeyword(keyParenR, *argClose));
}
if (depth) {
errorString = "mismatched parenthesis in condition";