Skip to content

Commit 7fdbd8f

Browse files
committed
Use set instead of list
1 parent e8b2b5e commit 7fdbd8f

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/checkclass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,11 @@ void CheckClass::checkMemset()
10521052
type = typeTok->type()->classScope;
10531053

10541054
if (type) {
1055-
std::list<const Scope *> parsedTypes;
1055+
std::set<const Scope *> parsedTypes;
10561056
checkMemsetType(scope, tok, type, false, parsedTypes);
10571057
}
10581058
} else if (tok->variable() && tok->variable()->typeScope() && Token::Match(tok, "%var% = calloc|malloc|realloc|g_malloc|g_try_malloc|g_realloc|g_try_realloc (")) {
1059-
std::list<const Scope *> parsedTypes;
1059+
std::set<const Scope *> parsedTypes;
10601060
checkMemsetType(scope, tok->tokAt(2), tok->variable()->typeScope(), true, parsedTypes);
10611061

10621062
if (tok->variable()->typeScope()->numConstructors > 0 && printWarnings)
@@ -1066,12 +1066,12 @@ void CheckClass::checkMemset()
10661066
}
10671067
}
10681068

1069-
void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::list<const Scope *> parsedTypes)
1069+
void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::set<const Scope *> parsedTypes)
10701070
{
10711071
// If type has been checked there is no need to check it again
1072-
if (std::find(parsedTypes.begin(), parsedTypes.end(), type) != parsedTypes.end())
1072+
if (parsedTypes.find(type) != parsedTypes.end())
10731073
return;
1074-
parsedTypes.push_back(type);
1074+
parsedTypes.insert(type);
10751075

10761076
const bool printPortability = _settings->isEnabled("portability");
10771077

lib/checkclass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CPPCHECKLIB CheckClass : public Check {
9999
* Important: The checking doesn't work on simplified tokens list.
100100
*/
101101
void checkMemset();
102-
void checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::list<const Scope *> parsedTypes);
102+
void checkMemsetType(const Scope *start, const Token *tok, const Scope *type, bool allocation, std::set<const Scope *> parsedTypes);
103103

104104
/** @brief 'operator=' should return something and it should not be const. */
105105
void operatorEq();

0 commit comments

Comments
 (0)