From dc5c5de10e4ce27a33674d04a168735ba266d22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 18 Dec 2022 19:38:29 +0100 Subject: [PATCH] avoid some unnecessary copies (#4589) --- lib/utils.cpp | 5 ++--- lib/valueflow.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/utils.cpp b/lib/utils.cpp index f7dd43864..834314443 100644 --- a/lib/utils.cpp +++ b/lib/utils.cpp @@ -126,8 +126,7 @@ void strTolower(std::string& str) { // This wrapper exists because Sun's CC does not allow a static_cast // from extern "C" int(*)(int) to int(*)(int). - static auto tolowerWrapper = [](int c) { + std::transform(str.begin(), str.end(), str.begin(), [](int c) { return std::tolower(c); - }; - std::transform(str.begin(), str.end(), str.begin(), tolowerWrapper); + }); } diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 5eb56fc9c..cab427931 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3840,8 +3840,8 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog std::list values = tok->values(); // Only forward lifetime values values.remove_if(&isNotLifetimeValue); - for (const ValueFlow::Value& value:values) - setTokenValue(parent, value, tokenlist->getSettings()); + for (ValueFlow::Value& value:values) + setTokenValue(parent, std::move(value), tokenlist->getSettings()); valueFlowForwardLifetime(parent, tokenlist, errorLogger, settings); } }