Cache and reuse values

This commit is contained in:
Dmitry-Me 2017-09-04 17:55:45 +03:00
parent 5dba8268e7
commit c29f16a306
1 changed files with 6 additions and 4 deletions

View File

@ -3729,8 +3729,9 @@ const Enumerator * SymbolDatabase::findEnumerator(const Token * tok) const
const Type* SymbolDatabase::findVariableTypeInBase(const Scope* scope, const Token* typeTok) const
{
if (scope && scope->definedType && !scope->definedType->derivedFrom.empty()) {
for (std::size_t i = 0; i < scope->definedType->derivedFrom.size(); ++i) {
const Type *base = scope->definedType->derivedFrom[i].type;
const std::vector<Type::BaseInfo> &derivedFrom = scope->definedType->derivedFrom;
for (std::size_t i = 0; i < derivedFrom.size(); ++i) {
const Type *base = derivedFrom[i].type;
if (base && base->classScope) {
const Type * type = base->classScope->findType(typeTok->str());
if (type)
@ -3862,8 +3863,9 @@ bool Scope::hasInlineOrLambdaFunction() const
void Scope::findFunctionInBase(const std::string & name, size_t args, std::vector<const Function *> & matches) const
{
if (isClassOrStruct() && definedType && !definedType->derivedFrom.empty()) {
for (std::size_t i = 0; i < definedType->derivedFrom.size(); ++i) {
const Type *base = definedType->derivedFrom[i].type;
const std::vector<Type::BaseInfo> &derivedFrom = definedType->derivedFrom;
for (std::size_t i = 0; i < derivedFrom.size(); ++i) {
const Type *base = derivedFrom[i].type;
if (base && base->classScope) {
if (base->classScope == this) // Ticket #5120, #5125: Recursive class; tok should have been found already
continue;