Skip to content

Commit b82e927

Browse files
committed
refs #10663 - Library: pre-calculate if Container::startPattern starts with std::
1 parent ec9415e commit b82e927

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/library.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
619619
container.startPattern2 = startPattern;
620620
if (!endsWith(container.startPattern, '<'))
621621
container.startPattern2 += " !!::";
622+
container.startPatternHasStd = startsWith(container.startPattern2, "std :: ");
622623
}
623624
const char* const endPattern = node->Attribute("endPattern");
624625
if (endPattern)
@@ -1402,11 +1403,10 @@ const Library::Container* Library::detectContainerInternal(const Token* const ty
14021403
if (container.startPattern.empty())
14031404
continue;
14041405

1405-
const bool startsWithStd = startsWith(container.startPattern2, "std :: ");
1406-
if (startsWithStd && !withoutStd && !hasScope)
1406+
if (container.startPatternHasStd && !withoutStd && !hasScope)
14071407
continue;
14081408

1409-
const int offset = (withoutStd && startsWithStd) ? 7 : 0;
1409+
const int offset = (withoutStd && container.startPatternHasStd ) ? 7 : 0;
14101410

14111411
// If endPattern is undefined, it will always match, but itEndPattern has to be defined.
14121412
if (detect != IteratorOnly && container.endPattern.empty()) {

lib/library.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class CPPCHECKLIB Library {
239239
bool unstableErase{};
240240
bool unstableInsert{};
241241
bool view{};
242+
bool startPatternHasStd{};
242243

243244
Action getAction(const std::string& function) const {
244245
const auto i = utils::as_const(functions).find(function);

0 commit comments

Comments
 (0)