Refactoring: Use STL algorithms

This commit is contained in:
Daniel Marjamäki 2019-04-28 07:30:17 +02:00
parent c8dce14303
commit 69faa0d8c8
1 changed files with 12 additions and 15 deletions

View File

@ -924,11 +924,10 @@ public:
const ValueFlow::Value * getValue(const MathLib::bigint val) const { const ValueFlow::Value * getValue(const MathLib::bigint val) const {
if (!mImpl->mValues) if (!mImpl->mValues)
return nullptr; return nullptr;
for (const ValueFlow::Value &value : *mImpl->mValues) { const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [=](const ValueFlow::Value &value) {
if (value.isIntValue() && value.intvalue == val) return value.isIntValue() && value.intvalue == val;
return &value; });
} return it == mImpl->mValues->end() ? nullptr : &*it;;
return nullptr;
} }
const ValueFlow::Value * getMaxValue(bool condition) const { const ValueFlow::Value * getMaxValue(bool condition) const {
@ -948,11 +947,10 @@ public:
const ValueFlow::Value * getMovedValue() const { const ValueFlow::Value * getMovedValue() const {
if (!mImpl->mValues) if (!mImpl->mValues)
return nullptr; return nullptr;
for (const ValueFlow::Value &value : *mImpl->mValues) { const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [](const ValueFlow::Value &value) {
if (value.isMovedValue() && value.moveKind != ValueFlow::Value::NonMovedVariable) return value.isMovedValue() && value.moveKind != ValueFlow::Value::NonMovedVariable;
return &value; });
} return it == mImpl->mValues->end() ? nullptr : &*it;;
return nullptr;
} }
const ValueFlow::Value * getValueLE(const MathLib::bigint val, const Settings *settings) const; const ValueFlow::Value * getValueLE(const MathLib::bigint val, const Settings *settings) const;
@ -963,11 +961,10 @@ public:
const ValueFlow::Value * getContainerSizeValue(const MathLib::bigint val) const { const ValueFlow::Value * getContainerSizeValue(const MathLib::bigint val) const {
if (!mImpl->mValues) if (!mImpl->mValues)
return nullptr; return nullptr;
for (const ValueFlow::Value &value : *mImpl->mValues) { const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [=](const ValueFlow::Value &value) {
if (value.isContainerSizeValue() && value.intvalue == val) return value.isContainerSizeValue() && value.intvalue == val;
return &value; });
} return it == mImpl->mValues->end() ? nullptr : &*it;;
return nullptr;
} }
const Token *getValueTokenMaxStrLength() const; const Token *getValueTokenMaxStrLength() const;