From 15b5b7ebf4176667da7cdfca6d53a6fa8b821bd3 Mon Sep 17 00:00:00 2001 From: jrp2014 Date: Fri, 6 Apr 2018 08:00:10 +0200 Subject: [PATCH] Refactor lib/checkother.cpp --- lib/checkother.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 1131dac7c..38b196e8b 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1752,9 +1752,7 @@ void CheckOther::checkDuplicateBranch() const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); - std::list::const_iterator scope; - - for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { + for (std::list::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { if (scope->type != Scope::eIf) continue; @@ -1891,19 +1889,17 @@ namespace { void getConstFunctions(const SymbolDatabase *symbolDatabase, std::list &constFunctions) { - std::list::const_iterator scope; - for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { - std::list::const_iterator func; + for (std::list::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { // only add const functions that do not have a non-const overloaded version // since it is pretty much impossible to tell which is being called. typedef std::map > StringFunctionMap; StringFunctionMap functionsByName; - for (func = scope->functionList.begin(); func != scope->functionList.end(); ++func) { + for (std::list::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) { functionsByName[func->tokenDef->str()].push_back(&*func); } for (StringFunctionMap::iterator it = functionsByName.begin(); it != functionsByName.end(); ++it) { - std::list::const_iterator nc = std::find_if(it->second.begin(), it->second.end(), notconst); + const std::list::const_iterator nc = std::find_if(it->second.begin(), it->second.end(), notconst); if (nc == it->second.end()) { // ok to add all of them constFunctions.splice(constFunctions.end(), it->second); @@ -1923,11 +1919,10 @@ void CheckOther::checkDuplicateExpression() // Parse all executing scopes.. const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); - std::list::const_iterator scope; std::list constFunctions; getConstFunctions(symbolDatabase, constFunctions); - for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { + for (std::list::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { // only check functions if (scope->type != Scope::eFunction) continue;