From 7fdbd8f0caf22744cb661262d953c0c191aca203 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 25 Dec 2015 16:19:27 +0300 Subject: [PATCH] Use set instead of list --- lib/checkclass.cpp | 10 +++++----- lib/checkclass.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index de95d1bf5..f8e1d303b 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1052,11 +1052,11 @@ void CheckClass::checkMemset() type = typeTok->type()->classScope; if (type) { - std::list parsedTypes; + std::set 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 (")) { - std::list parsedTypes; + std::set parsedTypes; checkMemsetType(scope, tok->tokAt(2), tok->variable()->typeScope(), true, parsedTypes); 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 parsedTypes) +void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::set parsedTypes) { // 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; - parsedTypes.push_back(type); + parsedTypes.insert(type); const bool printPortability = _settings->isEnabled("portability"); diff --git a/lib/checkclass.h b/lib/checkclass.h index 3ed901f38..92c80b7c9 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -99,7 +99,7 @@ public: * Important: The checking doesn't work on simplified tokens list. */ void checkMemset(); - void checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::list parsedTypes); + void checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::set parsedTypes); /** @brief 'operator=' should return something and it should not be const. */ void operatorEq();