SymbolDatabase::createSymbolDatabaseSetTypePointers: Optimize ~90%

This commit is contained in:
Daniel Marjamäki 2018-05-09 13:48:55 +02:00
parent ab6167e3e6
commit 129bdb2752
1 changed files with 8 additions and 0 deletions

View File

@ -1049,11 +1049,19 @@ void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass)
void SymbolDatabase::createSymbolDatabaseSetTypePointers() void SymbolDatabase::createSymbolDatabaseSetTypePointers()
{ {
std::set<std::string> typenames;
for (const Type &t : typeList) {
typenames.insert(t.name());
}
// Set type pointers // Set type pointers
for (const Token* tok = _tokenizer->list.front(); tok != _tokenizer->list.back(); tok = tok->next()) { for (const Token* tok = _tokenizer->list.front(); tok != _tokenizer->list.back(); tok = tok->next()) {
if (!tok->isName() || tok->varId() || tok->function() || tok->type() || tok->enumerator()) if (!tok->isName() || tok->varId() || tok->function() || tok->type() || tok->enumerator())
continue; continue;
if (typenames.find(tok->str()) == typenames.end())
continue;
const Type *type = findVariableType(tok->scope(), tok); const Type *type = findVariableType(tok->scope(), tok);
if (type) if (type)
const_cast<Token *>(tok)->type(type); const_cast<Token *>(tok)->type(type);