Refactoring; Use range for in SymbolDatabase

This commit is contained in:
Daniel Marjamäki 2021-08-01 21:51:37 +02:00
parent 1ec7397c21
commit 0f0d042ee2
1 changed files with 17 additions and 24 deletions

View File

@ -5262,9 +5262,9 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const
const Scope *SymbolDatabase::findScopeByName(const std::string& name) const const Scope *SymbolDatabase::findScopeByName(const std::string& name) const
{ {
for (std::list<Scope>::const_iterator it = scopeList.begin(); it != scopeList.end(); ++it) { for (const Scope &scope: scopeList) {
if (it->className == name) if (scope.className == name)
return &*it; return &scope;
} }
return nullptr; return nullptr;
} }
@ -5273,11 +5273,9 @@ const Scope *SymbolDatabase::findScopeByName(const std::string& name) const
Scope *Scope::findInNestedList(const std::string & name) Scope *Scope::findInNestedList(const std::string & name)
{ {
std::list<Scope *>::iterator it; for (Scope *scope: nestedList) {
if (scope->className == name)
for (it = nestedList.begin(); it != nestedList.end(); ++it) { return scope;
if ((*it)->className == name)
return (*it);
} }
return nullptr; return nullptr;
} }
@ -5286,11 +5284,9 @@ Scope *Scope::findInNestedList(const std::string & name)
const Scope *Scope::findRecordInNestedList(const std::string & name) const const Scope *Scope::findRecordInNestedList(const std::string & name) const
{ {
std::list<Scope *>::const_iterator it; for (const Scope* scope: nestedList) {
if (scope->className == name && scope->type != eFunction)
for (it = nestedList.begin(); it != nestedList.end(); ++it) { return scope;
if ((*it)->className == name && (*it)->type != eFunction)
return (*it);
} }
const Type * nested_type = findType(name); const Type * nested_type = findType(name);
@ -5336,15 +5332,13 @@ const Type* Scope::findType(const std::string & name) const
Scope *Scope::findInNestedListRecursive(const std::string & name) Scope *Scope::findInNestedListRecursive(const std::string & name)
{ {
std::list<Scope *>::iterator it; for (Scope *scope: nestedList) {
if (scope->className == name)
for (it = nestedList.begin(); it != nestedList.end(); ++it) { return scope;
if ((*it)->className == name)
return (*it);
} }
for (it = nestedList.begin(); it != nestedList.end(); ++it) { for (Scope* scope: nestedList) {
Scope *child = (*it)->findInNestedListRecursive(name); Scope *child = scope->findInNestedListRecursive(name);
if (child) if (child)
return child; return child;
} }
@ -5355,10 +5349,9 @@ Scope *Scope::findInNestedListRecursive(const std::string & name)
const Function *Scope::getDestructor() const const Function *Scope::getDestructor() const
{ {
std::list<Function>::const_iterator it; for (const Function &function: functionList) {
for (it = functionList.begin(); it != functionList.end(); ++it) { if (function.type == Function::eDestructor)
if (it->type == Function::eDestructor) return &function;
return &(*it);
} }
return nullptr; return nullptr;
} }