Refactoring, use early return

This commit is contained in:
Daniel Marjamäki 2018-04-04 10:50:10 +02:00
parent 7efc4dd26e
commit 3b07b749d6
1 changed files with 30 additions and 29 deletions

View File

@ -851,42 +851,43 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
void SymbolDatabase::createSymbolDatabaseClassInfo() void SymbolDatabase::createSymbolDatabaseClassInfo()
{ {
if (!_tokenizer->isC()) { if (_tokenizer->isC())
// fill in using info return;
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
for (std::list<Scope::UsingInfo>::iterator i = it->usingList.begin(); i != it->usingList.end(); ++i) { // fill in using info
// only find if not already found for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
if (i->scope == nullptr) { for (std::list<Scope::UsingInfo>::iterator i = it->usingList.begin(); i != it->usingList.end(); ++i) {
// check scope for match // only find if not already found
Scope *scope = findScope(i->start->tokAt(2), &(*it)); if (i->scope == nullptr) {
if (scope) { // check scope for match
// set found scope Scope *scope = findScope(i->start->tokAt(2), &(*it));
i->scope = scope; if (scope) {
break; // set found scope
} i->scope = scope;
break;
} }
} }
} }
}
// fill in base class info // fill in base class info
for (std::list<Type>::iterator it = typeList.begin(); it != typeList.end(); ++it) { for (std::list<Type>::iterator it = typeList.begin(); it != typeList.end(); ++it) {
// finish filling in base class info // finish filling in base class info
for (unsigned int i = 0; i < it->derivedFrom.size(); ++i) { for (unsigned int i = 0; i < it->derivedFrom.size(); ++i) {
const Type* found = findType(it->derivedFrom[i].nameTok, it->enclosingScope); const Type* found = findType(it->derivedFrom[i].nameTok, it->enclosingScope);
if (found && found->findDependency(&(*it))) { if (found && found->findDependency(&(*it))) {
// circular dependency // circular dependency
//_tokenizer->syntaxError(nullptr); //_tokenizer->syntaxError(nullptr);
} else { } else {
it->derivedFrom[i].type = found; it->derivedFrom[i].type = found;
}
} }
} }
}
// fill in friend info // fill in friend info
for (std::list<Type>::iterator it = typeList.begin(); it != typeList.end(); ++it) { for (std::list<Type>::iterator it = typeList.begin(); it != typeList.end(); ++it) {
for (std::list<Type::FriendInfo>::iterator i = it->friendList.begin(); i != it->friendList.end(); ++i) { for (std::list<Type::FriendInfo>::iterator i = it->friendList.begin(); i != it->friendList.end(); ++i) {
i->type = findType(i->nameStart, it->enclosingScope); i->type = findType(i->nameStart, it->enclosingScope);
}
} }
} }
} }