avoid some unnecessary copies (#4589)

This commit is contained in:
Oliver Stöneberg 2022-12-18 19:38:29 +01:00 committed by GitHub
parent 0ed98c8f29
commit dc5c5de10e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -126,8 +126,7 @@ void strTolower(std::string& str)
{ {
// This wrapper exists because Sun's CC does not allow a static_cast // This wrapper exists because Sun's CC does not allow a static_cast
// from extern "C" int(*)(int) to int(*)(int). // 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); return std::tolower(c);
}; });
std::transform(str.begin(), str.end(), str.begin(), tolowerWrapper);
} }

View File

@ -3840,8 +3840,8 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog
std::list<ValueFlow::Value> values = tok->values(); std::list<ValueFlow::Value> values = tok->values();
// Only forward lifetime values // Only forward lifetime values
values.remove_if(&isNotLifetimeValue); values.remove_if(&isNotLifetimeValue);
for (const ValueFlow::Value& value:values) for (ValueFlow::Value& value:values)
setTokenValue(parent, value, tokenlist->getSettings()); setTokenValue(parent, std::move(value), tokenlist->getSettings());
valueFlowForwardLifetime(parent, tokenlist, errorLogger, settings); valueFlowForwardLifetime(parent, tokenlist, errorLogger, settings);
} }
} }