@@ -3972,8 +3972,8 @@ void Tokenizer::simplifyTemplates()
3972
3972
/* * Class used in Tokenizer::setVarIdPass1 */
3973
3973
class VariableMap {
3974
3974
private:
3975
- std::map <std::string, nonneg int > mVariableId ;
3976
- std::map <std::string, nonneg int > mVariableId_global ;
3975
+ std::unordered_map <std::string, nonneg int > mVariableId ;
3976
+ std::unordered_map <std::string, nonneg int > mVariableId_global ;
3977
3977
std::stack<std::vector<std::pair<std::string, nonneg int >>> mScopeInfo ;
3978
3978
mutable nonneg int mVarId ;
3979
3979
public:
@@ -3985,7 +3985,7 @@ class VariableMap {
3985
3985
return mVariableId .find (varname) != mVariableId .end ();
3986
3986
}
3987
3987
3988
- const std::map <std::string, nonneg int >& map (bool global) const {
3988
+ const std::unordered_map <std::string, nonneg int >& map (bool global) const {
3989
3989
return global ? mVariableId_global : mVariableId ;
3990
3990
}
3991
3991
nonneg int getVarId () const {
@@ -4025,7 +4025,7 @@ void VariableMap::addVariable(const std::string& varname, bool globalNamespace)
4025
4025
mVariableId_global [varname] = mVariableId [varname];
4026
4026
return ;
4027
4027
}
4028
- std::map <std::string, nonneg int >::iterator it = mVariableId .find (varname);
4028
+ std::unordered_map <std::string, nonneg int >::iterator it = mVariableId .find (varname);
4029
4029
if (it == mVariableId .end ()) {
4030
4030
mScopeInfo .top ().emplace_back (varname, 0 );
4031
4031
mVariableId [varname] = ++mVarId ;
@@ -4277,7 +4277,7 @@ void Tokenizer::setVarIdClassDeclaration(const Token * const startToken,
4277
4277
--indentlevel;
4278
4278
inEnum = false ;
4279
4279
} else if (initList && indentlevel == 0 && Token::Match (tok->previous (), " [,:] %name% [({]" )) {
4280
- const std::map <std::string, nonneg int >::const_iterator it = variableMap.map (false ).find (tok->str ());
4280
+ const std::unordered_map <std::string, nonneg int >::const_iterator it = variableMap.map (false ).find (tok->str ());
4281
4281
if (it != variableMap.map (false ).end ()) {
4282
4282
tok->varId (it->second );
4283
4283
}
@@ -4295,7 +4295,7 @@ void Tokenizer::setVarIdClassDeclaration(const Token * const startToken,
4295
4295
}
4296
4296
4297
4297
if (!inEnum) {
4298
- const std::map <std::string, nonneg int >::const_iterator it = variableMap.map (false ).find (tok->str ());
4298
+ const std::unordered_map <std::string, nonneg int >::const_iterator it = variableMap.map (false ).find (tok->str ());
4299
4299
if (it != variableMap.map (false ).end ()) {
4300
4300
tok->varId (it->second );
4301
4301
setVarIdStructMembers (&tok, structMembers, variableMap.getVarId ());
@@ -4637,7 +4637,7 @@ void Tokenizer::setVarIdPass1()
4637
4637
while (tok != end) {
4638
4638
if (tok->isName () && !(Token::simpleMatch (tok->next (), " <" ) &&
4639
4639
Token::Match (tok->tokAt (-1 ), " :: %name%" ))) {
4640
- const std::map <std::string, nonneg int >::const_iterator it = variableMap.map (false ).find (tok->str ());
4640
+ const std::unordered_map <std::string, nonneg int >::const_iterator it = variableMap.map (false ).find (tok->str ());
4641
4641
if (it != variableMap.map (false ).end ())
4642
4642
tok->varId (it->second );
4643
4643
}
@@ -4702,7 +4702,7 @@ void Tokenizer::setVarIdPass1()
4702
4702
}
4703
4703
4704
4704
if (!scopeStack.top ().isEnum || !(Token::Match (tok->previous (), " {|," ) && Token::Match (tok->next (), " ,|=|}" ))) {
4705
- const std::map <std::string, nonneg int >::const_iterator it = variableMap.map (globalNamespace).find (tok->str ());
4705
+ const std::unordered_map <std::string, nonneg int >::const_iterator it = variableMap.map (globalNamespace).find (tok->str ());
4706
4706
if (it != variableMap.map (globalNamespace).end ()) {
4707
4707
tok->varId (it->second );
4708
4708
setVarIdStructMembers (&tok, structMembers, variableMap.getVarId ());
@@ -5745,6 +5745,7 @@ void Tokenizer::dump(std::ostream &out) const
5745
5745
5746
5746
std::set<const Library::Container*> containers;
5747
5747
5748
+ // TODO: avoid ostream usage
5748
5749
// tokens..
5749
5750
outs += " <tokenlist>" ;
5750
5751
outs += ' \n ' ;
@@ -10437,9 +10438,9 @@ bool Tokenizer::hasIfdef(const Token *start, const Token *end) const
10437
10438
10438
10439
return std::any_of (mPreprocessor ->getDirectives ().cbegin (), mPreprocessor ->getDirectives ().cend (), [&](const Directive& d) {
10439
10440
return d.str .compare (0 , 3 , " #if" ) == 0 &&
10440
- d.linenr >= start->linenr () &&
10441
- d.linenr <= end->linenr () &&
10442
- start->fileIndex () < list.getFiles ().size () &&
10443
- d.file == list.getFiles ()[start->fileIndex ()];
10441
+ d.linenr >= start->linenr () &&
10442
+ d.linenr <= end->linenr () &&
10443
+ start->fileIndex () < list.getFiles ().size () &&
10444
+ d.file == list.getFiles ()[start->fileIndex ()];
10444
10445
});
10445
10446
}
0 commit comments