diff --git a/lib/token.h b/lib/token.h index bc57e09f1..fc2972dcb 100644 --- a/lib/token.h +++ b/lib/token.h @@ -924,11 +924,10 @@ public: const ValueFlow::Value * getValue(const MathLib::bigint val) const { if (!mImpl->mValues) return nullptr; - for (const ValueFlow::Value &value : *mImpl->mValues) { - if (value.isIntValue() && value.intvalue == val) - return &value; - } - return nullptr; + const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [=](const ValueFlow::Value &value) { + return value.isIntValue() && value.intvalue == val; + }); + return it == mImpl->mValues->end() ? nullptr : &*it;; } const ValueFlow::Value * getMaxValue(bool condition) const { @@ -948,11 +947,10 @@ public: const ValueFlow::Value * getMovedValue() const { if (!mImpl->mValues) return nullptr; - for (const ValueFlow::Value &value : *mImpl->mValues) { - if (value.isMovedValue() && value.moveKind != ValueFlow::Value::NonMovedVariable) - return &value; - } - return nullptr; + const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [](const ValueFlow::Value &value) { + return value.isMovedValue() && value.moveKind != ValueFlow::Value::NonMovedVariable; + }); + return it == mImpl->mValues->end() ? nullptr : &*it;; } 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 { if (!mImpl->mValues) return nullptr; - for (const ValueFlow::Value &value : *mImpl->mValues) { - if (value.isContainerSizeValue() && value.intvalue == val) - return &value; - } - return nullptr; + const auto it = std::find_if(mImpl->mValues->begin(), mImpl->mValues->end(), [=](const ValueFlow::Value &value) { + return value.isContainerSizeValue() && value.intvalue == val; + }); + return it == mImpl->mValues->end() ? nullptr : &*it;; } const Token *getValueTokenMaxStrLength() const;