Merge pull request #744 from Dmitry-Me/useSetInsteadofList

Use set instead of list
This commit is contained in:
PKEuS 2015-12-25 15:57:22 +01:00
commit 0bdd353062
2 changed files with 6 additions and 6 deletions

View File

@ -1052,11 +1052,11 @@ void CheckClass::checkMemset()
type = typeTok->type()->classScope; type = typeTok->type()->classScope;
if (type) { if (type) {
std::list<const Scope *> parsedTypes; std::set<const Scope *> parsedTypes;
checkMemsetType(scope, tok, type, false, parsedTypes); checkMemsetType(scope, tok, type, false, parsedTypes);
} }
} else if (tok->variable() && tok->variable()->typeScope() && Token::Match(tok, "%var% = calloc|malloc|realloc|g_malloc|g_try_malloc|g_realloc|g_try_realloc (")) { } else if (tok->variable() && tok->variable()->typeScope() && Token::Match(tok, "%var% = calloc|malloc|realloc|g_malloc|g_try_malloc|g_realloc|g_try_realloc (")) {
std::list<const Scope *> parsedTypes; std::set<const Scope *> parsedTypes;
checkMemsetType(scope, tok->tokAt(2), tok->variable()->typeScope(), true, parsedTypes); checkMemsetType(scope, tok->tokAt(2), tok->variable()->typeScope(), true, parsedTypes);
if (tok->variable()->typeScope()->numConstructors > 0 && printWarnings) if (tok->variable()->typeScope()->numConstructors > 0 && printWarnings)
@ -1066,12 +1066,12 @@ void CheckClass::checkMemset()
} }
} }
void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::list<const Scope *> parsedTypes) void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::set<const Scope *> parsedTypes)
{ {
// If type has been checked there is no need to check it again // If type has been checked there is no need to check it again
if (std::find(parsedTypes.begin(), parsedTypes.end(), type) != parsedTypes.end()) if (parsedTypes.find(type) != parsedTypes.end())
return; return;
parsedTypes.push_back(type); parsedTypes.insert(type);
const bool printPortability = _settings->isEnabled("portability"); const bool printPortability = _settings->isEnabled("portability");

View File

@ -99,7 +99,7 @@ public:
* Important: The checking doesn't work on simplified tokens list. * Important: The checking doesn't work on simplified tokens list.
*/ */
void checkMemset(); void checkMemset();
void checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::list<const Scope *> parsedTypes); void checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::set<const Scope *> parsedTypes);
/** @brief 'operator=' should return something and it should not be const. */ /** @brief 'operator=' should return something and it should not be const. */
void operatorEq(); void operatorEq();