Refactoring: Use STL algorithms
This commit is contained in:
parent
c8dce14303
commit
69faa0d8c8
27
lib/token.h
27
lib/token.h
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue