Small refactorization: Handle std::map more efficient in setVarIdStructMembers()

This commit is contained in:
PKEuS 2012-08-28 12:57:11 +02:00
parent ea85dd305a
commit bbce79d7b3
1 changed files with 4 additions and 15 deletions

View File

@ -2539,23 +2539,12 @@ static void setVarIdStructMembers(Token **tok1,
if (TemplateSimplifier::templateParameters(tok->next()) > 0)
break;
std::map<unsigned int, std::map<std::string,unsigned int> >::iterator structIterator;
structIterator = structMembers->find(struct_varid);
if (structIterator == structMembers->end()) {
std::map<std::string,unsigned int> members;
members[tok->str()] = ++ (*_varId);
(*structMembers)[struct_varid] = members;
std::map<std::string,unsigned int>& members = (*structMembers)[struct_varid];
if (members.empty() || members.find(tok->str()) == members.end()) {
members[tok->str()] = ++(*_varId);
tok->varId(*_varId);
} else {
std::map<std::string,unsigned int> &members = structIterator->second;
std::map<std::string,unsigned int>::const_iterator memberIterator;
memberIterator = members.find(tok->str());
if (memberIterator == members.end()) {
members[tok->str()] = ++(*_varId);
tok->varId(*_varId);
} else {
tok->varId(memberIterator->second);
}
tok->varId(members[tok->str()]);
}
}
if (tok)