Skip to content

Commit

Permalink
Library: pre-calculate if Container has std namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Jan 22, 2024
1 parent d52ce4e commit d12ba0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
container.startPattern2 = startPattern;
if (!endsWith(container.startPattern, '<'))
container.startPattern2 += " !!::";
container.isStd = startsWith(container.startPattern, "std ::");
}
const char* const endPattern = node->Attribute("endPattern");
if (endPattern)
Expand Down Expand Up @@ -1186,7 +1187,7 @@ const Library::Container* Library::detectContainerInternal(const Token* const ty
if (container.startPattern.empty())
continue;

const int offset = (withoutStd && startsWith(container.startPattern2, "std :: ")) ? 7 : 0;
const int offset = (withoutStd && container.isStd) ? 7 : 0;

// If endPattern is undefined, it will always match, but itEndPattern has to be defined.
if (detect != IteratorOnly && container.endPattern.empty()) {
Expand Down
1 change: 1 addition & 0 deletions lib/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class CPPCHECKLIB Library {
bool unstableErase{};
bool unstableInsert{};
bool view{};
bool isStd{};

Action getAction(const std::string& function) const {
const std::map<std::string, Function>::const_iterator i = functions.find(function);
Expand Down

0 comments on commit d12ba0b

Please sign in to comment.