Symbol database: faster implementation. Ticket: #4494

This commit is contained in:
Robert Reif 2013-02-20 07:46:06 +01:00 committed by Daniel Marjamäki
parent 71b66209b7
commit 21bf5173e5
1 changed files with 15 additions and 20 deletions

View File

@ -892,28 +892,23 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
} }
// fill in missing variables if possible // fill in missing variables if possible
for (std::size_t i = 1; i <= _tokenizer->varIdCount(); i++) { const std::size_t functions = functionScopes.size();
// check each missing variable for (std::size_t i = 0; i < functions; ++i) {
if (_variableList[i] == 0) { const Scope *func = functionScopes[i];
// find the token with this varid for (const Token *tok = func->classStart->next(); tok != func->classEnd; tok = tok->next()) {
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { // check for member variable
if (tok->varId() == i) { if (tok && tok->varId() && tok->next() && tok->next()->str() == ".") {
// check if it is a member variable const Token *tok1 = tok->tokAt(2);
const Token *tok1 = tok->tokAt(-2); if (tok1 && tok1->varId() && _variableList[tok1->varId()] == 0) {
if (tok1 && Token::Match(tok1, "%var% .") && tok1->varId()) { const Variable *var = _variableList[tok->varId()];
// check if this varid has a variable if (var && var->type()) {
const Variable *var = getVariableFromVarId(tok1->varId()); // find the member variable of this variable
if (var && var->type()) { const Variable *var1 = var->type()->getVariable(tok1->str());
// find the member variable of this variable if (var1) {
const Variable *var1 = var->type()->getVariable(tok->str()); // add this variable to the look up table
if (var1) { _variableList[tok1->varId()] = var1;
// add this variable to the look up table
_variableList[i] = var1;
}
} }
} }
// found varid so stop searching
break;
} }
} }
} }