From 8032f64c15fbfeb9525e4e7e3464bcdacadeaefd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 10 Aug 2018 10:04:10 +0200 Subject: [PATCH] Refactoring; Use range for loops --- lib/token.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/token.h b/lib/token.h index 2aa038d51..6134827ec 100644 --- a/lib/token.h +++ b/lib/token.h @@ -839,9 +839,9 @@ public: const ValueFlow::Value * getValue(const MathLib::bigint val) const { if (!mValues) return nullptr; - for (std::list::const_iterator it = mValues->begin(); it != mValues->end(); ++it) { - if (it->isIntValue() && it->intvalue == val) - return &(*it); + for (const ValueFlow::Value &value : *mValues) { + if (value.isIntValue() && value.intvalue == val) + return &value; } return nullptr; } @@ -850,12 +850,12 @@ public: if (!mValues) return nullptr; const ValueFlow::Value *ret = nullptr; - for (std::list::const_iterator it = mValues->begin(); it != mValues->end(); ++it) { - if (!it->isIntValue()) + for (const ValueFlow::Value &value : *mValues) { + if (!value.isIntValue()) continue; - if ((!ret || it->intvalue > ret->intvalue) && - ((it->condition != nullptr) == condition)) - ret = &(*it); + if ((!ret || value.intvalue > ret->intvalue) && + ((value.condition != nullptr) == condition)) + ret = &value; } return ret; } @@ -863,9 +863,9 @@ public: const ValueFlow::Value * getMovedValue() const { if (!mValues) return nullptr; - for (std::list::const_iterator it = mValues->begin(); it != mValues->end(); ++it) { - if (it->isMovedValue() && it->moveKind != ValueFlow::Value::NonMovedVariable) - return &(*it); + for (const ValueFlow::Value &value : *mValues) { + if (value.isMovedValue() && value.moveKind != ValueFlow::Value::NonMovedVariable) + return &value; } return nullptr; }