@@ -419,7 +419,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
419419
420420 const char * const inherits = node->Attribute (" inherits" );
421421 if (inherits) {
422- const std::map <std::string, Container>::const_iterator i = containers.find (inherits);
422+ const std::unordered_map <std::string, Container>::const_iterator i = containers.find (inherits);
423423 if (i != containers.end ())
424424 container = i->second ; // Take values from parent and overwrite them if necessary
425425 else
@@ -1158,8 +1158,17 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const
11581158 return false ;
11591159}
11601160
1161- const Library::Container* Library::detectContainerInternal (const Token* typeStart, DetectContainer detect, bool * isIterator, bool withoutStd) const
1161+ const Library::Container* Library::detectContainerInternal (const Token* const typeStart, DetectContainer detect, bool * isIterator, bool withoutStd) const
11621162{
1163+ const Token* firstLinkedTok = nullptr ;
1164+ for (const Token* tok = typeStart; tok && !tok->varId (); tok = tok->next ()) {
1165+ if (!tok->link ())
1166+ continue ;
1167+
1168+ firstLinkedTok = tok;
1169+ break ;
1170+ }
1171+
11631172 for (const std::pair<const std::string, Library::Container> & c : containers) {
11641173 const Container& container = c.second ;
11651174 if (container.startPattern .empty ())
@@ -1177,23 +1186,22 @@ const Library::Container* Library::detectContainerInternal(const Token* typeStar
11771186 return &container;
11781187 }
11791188
1180- for (const Token* tok = typeStart; tok && !tok->varId (); tok = tok->next ()) {
1181- if (!tok->link ())
1182- continue ;
1189+ if (!firstLinkedTok)
1190+ continue ;
11831191
1184- const bool matchedStartPattern = Token::Match (typeStart, container.startPattern2 .c_str () + offset);
1192+ const bool matchedStartPattern = Token::Match (typeStart, container.startPattern2 .c_str () + offset);
1193+ if (!matchedStartPattern)
1194+ continue ;
11851195
1186- if (detect != ContainerOnly && matchedStartPattern && Token::Match (tok->link (), container.itEndPattern .c_str ())) {
1187- if (isIterator)
1188- *isIterator = true ;
1189- return &container;
1190- }
1191- if (detect != IteratorOnly && matchedStartPattern && Token::Match (tok->link (), container.endPattern .c_str ())) {
1192- if (isIterator)
1193- *isIterator = false ;
1194- return &container;
1195- }
1196- break ;
1196+ if (detect != ContainerOnly && Token::Match (firstLinkedTok->link (), container.itEndPattern .c_str ())) {
1197+ if (isIterator)
1198+ *isIterator = true ;
1199+ return &container;
1200+ }
1201+ if (detect != IteratorOnly && Token::Match (firstLinkedTok->link (), container.endPattern .c_str ())) {
1202+ if (isIterator)
1203+ *isIterator = false ;
1204+ return &container;
11971205 }
11981206 }
11991207 return nullptr ;
0 commit comments