From c29f16a3062ab97d2b9c44c16e20c359747abae3 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 4 Sep 2017 17:55:45 +0300 Subject: [PATCH] Cache and reuse values --- lib/symboldatabase.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a6924fb47..8589c94ea 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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 &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 & 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 &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;