Simplify array access with references

This commit is contained in:
Dmitry-Me 2017-08-28 18:19:03 +03:00
parent 7d19d1ea2e
commit 7bd3dc5da6
2 changed files with 8 additions and 5 deletions

View File

@ -743,8 +743,9 @@ std::string Library::getFunctionName(const Token *ftok, bool *error) const
for (const Scope *scope = ftok->scope(); scope; scope = scope->nestedIn) { for (const Scope *scope = ftok->scope(); scope; scope = scope->nestedIn) {
if (!scope->isClassOrStruct()) if (!scope->isClassOrStruct())
continue; continue;
for (unsigned int i = 0; i < scope->definedType->derivedFrom.size(); ++i) { const std::vector<Type::BaseInfo> &derivedFrom = scope->definedType->derivedFrom;
const Type::BaseInfo &baseInfo = scope->definedType->derivedFrom[i]; for (unsigned int i = 0; i < derivedFrom.size(); ++i) {
const Type::BaseInfo &baseInfo = derivedFrom[i];
const std::string name(baseInfo.name + "::" + ftok->str()); const std::string name(baseInfo.name + "::" + ftok->str());
if (functions.find(name) != functions.end() && matchArguments(ftok, name)) if (functions.find(name) != functions.end() && matchArguments(ftok, name))
return name; return name;

View File

@ -3680,9 +3680,11 @@ const Enumerator * SymbolDatabase::findEnumerator(const Token * tok) const
} }
if (scope->definedType) { if (scope->definedType) {
for (size_t i = 0, end = scope->definedType->derivedFrom.size(); i < end; ++i) { const std::vector<Type::BaseInfo> & derivedFrom = scope->definedType->derivedFrom;
if (scope->definedType->derivedFrom[i].type && scope->definedType->derivedFrom[i].type->classScope) { for (size_t i = 0, end = derivedFrom.size(); i < end; ++i) {
enumerator = scope->definedType->derivedFrom[i].type->classScope->findEnumerator(tok->str()); const Type *derivedFromType = derivedFrom[i].type;
if (derivedFromType && derivedFromType ->classScope) {
enumerator = derivedFromType->classScope->findEnumerator(tok->str());
if (enumerator) if (enumerator)
return enumerator; return enumerator;