Refactoring; replace for loop with std::find_if

This commit is contained in:
Daniel Marjamäki 2019-04-28 10:07:11 +02:00
parent aaf1af6736
commit f503386666
1 changed files with 3 additions and 5 deletions

View File

@ -63,11 +63,9 @@ static const CWE CWE_BUFFER_OVERRUN(788U); // Access of Memory Location After
static const ValueFlow::Value *getBufferSizeValue(const Token *tok)
{
for (const ValueFlow::Value &value : tok->values()) {
if (value.isBufferSizeValue())
return &value;
}
return nullptr;
const std::list<ValueFlow::Value> &tokenValues = tok->values();
const auto it = std::find_if(tokenValues.begin(), tokenValues.end(), std::mem_fn(&ValueFlow::Value::isBufferSizeValue));
return it == tokenValues.end() ? nullptr : &*it;
}
static size_t getMinFormatStringOutputLength(const std::vector<const Token*> &parameters, unsigned int formatStringArgNr)