speed up checkio by caching commonly looked up stuff in the symbol database (#4266)

This commit is contained in:
Robert Reif 2012-10-21 09:05:01 +02:00 committed by Daniel Marjamäki
parent 0e100f7563
commit 9bc2a62c1e
1 changed files with 21 additions and 21 deletions

View File

@ -188,32 +188,32 @@ void CheckLeakAutoVar::check()
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
// Check function scopes // Check function scopes
for (std::list<Scope>::const_iterator i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i) { const std::size_t functions = symbolDatabase->functionScopes.size();
if (i->type == Scope::eFunction) { for (std::size_t i = 0; i < functions; ++i) {
// Empty variable info const Scope * scope = symbolDatabase->functionScopes[i];
VarInfo varInfo; // Empty variable info
VarInfo varInfo;
// Local variables that are known to be non-zero. // Local variables that are known to be non-zero.
const std::set<unsigned int> notzero; const std::set<unsigned int> notzero;
checkScope(i->classStart, &varInfo, notzero); checkScope(scope->classStart, &varInfo, notzero);
varInfo.conditionalAlloc.clear(); varInfo.conditionalAlloc.clear();
// Clear reference arguments from varInfo.. // Clear reference arguments from varInfo..
std::map<unsigned int, std::string>::iterator it = varInfo.alloctype.begin(); std::map<unsigned int, std::string>::iterator it = varInfo.alloctype.begin();
while (it != varInfo.alloctype.end()) { while (it != varInfo.alloctype.end()) {
const Variable *var = symbolDatabase->getVariableFromVarId(it->first); const Variable *var = symbolDatabase->getVariableFromVarId(it->first);
if (!var || if (!var ||
(var->isArgument() && var->isReference()) || (var->isArgument() && var->isReference()) ||
(!var->isArgument() && !var->isLocal())) (!var->isArgument() && !var->isLocal()))
varInfo.alloctype.erase(it++); varInfo.alloctype.erase(it++);
else else
++it; ++it;
}
ret(i->classEnd, varInfo);
} }
ret(scope->classEnd, varInfo);
} }
} }