diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2021-07-27 20:22:10 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-08-03 14:55:47 (GMT) |
commit | 00961a4782d9b22adce4d75ea61eb2f1d16ad0e5 (patch) | |
tree | 02777343f855ddf0434196aa226706c035180dbb /Source | |
parent | 2a72cad9bec2e9bf2fafcde4e0affcf0a6afc96e (diff) | |
download | CMake-00961a4782d9b22adce4d75ea61eb2f1d16ad0e5.zip CMake-00961a4782d9b22adce4d75ea61eb2f1d16ad0e5.tar.gz CMake-00961a4782d9b22adce4d75ea61eb2f1d16ad0e5.tar.bz2 |
Refactor: Copy exactly required count of args and avoid `pop_back()`
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmConditionEvaluator.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index d55a89c..ea5dce5 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -498,18 +498,19 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs, status = MessageType::FATAL_ERROR; return false; } + // store the reduced args in this vector - auto argP1 = std::next(arg); - std::vector<cmExpandedCommandArgument> newArgs2{ argP1, argClose }; - newArgs2.pop_back(); + auto argOpen = std::next(arg); + const std::vector<cmExpandedCommandArgument> subExpr( + argOpen, std::prev(argClose)); // now recursively invoke IsTrue to handle the values inside the // parenthetical expression - const auto value = this->IsTrue(newArgs2, errorString, status); + const auto value = this->IsTrue(subExpr, errorString, status); *arg = cmExpandedCommandArgument(bool2string(value), true); - argP1 = std::next(arg); + argOpen = std::next(arg); // remove the now evaluated parenthetical expression - newArgs.erase(argP1, argClose); + newArgs.erase(argOpen, argClose); } } return true; |