Fixed #4942 (1.61 is very slow (compared to 1.60.1))

This commit is contained in:
Daniel Marjamäki 2013-08-16 18:39:56 +02:00
parent 538e4bd798
commit 67c77a31aa
1 changed files with 7 additions and 27 deletions

View File

@ -7565,14 +7565,11 @@ void Tokenizer::simplifyEnum()
bool hasClass = false;
EnumValue *ev = NULL;
int executableScopeLevel = 0;
if (!tok1)
return;
for (Token *tok2 = tok1->next(); tok2; tok2 = tok2->next()) {
if (tok2->str() == "}") {
--level;
--executableScopeLevel;
if (level < 0)
inScope = false;
@ -7596,40 +7593,23 @@ void Tokenizer::simplifyEnum()
// Not a duplicate enum..
++level;
if (executableScopeLevel > 0)
++executableScopeLevel;
// Create a copy of the shadow ids for the inner scope
if (!shadowId.empty())
shadowId.push(shadowId.top());
// are there shadow arguments?
if (Token::simpleMatch(tok2->previous(), ") {") || Token::simpleMatch(tok2->tokAt(-2), ") const {")) {
// Determine if this is a executable scope..
if (executableScopeLevel <= 0) {
const Token *prev = tok2->previous();
while (prev) {
if (prev->str() == "}" || prev->str() == ")")
prev = prev->link();
else if (prev->str() == "{") {
while ((prev = prev->previous()) && (prev->isName()));
if (!prev || prev->str() == ")")
break;
}
prev = prev->previous();
}
if (prev)
executableScopeLevel = 1;
}
bool executableScope = (executableScopeLevel > 0);
std::set<std::string> shadowArg;
for (const Token* arg = tok2; arg && arg->str() != "("; arg = arg->previous()) {
if (Token::Match(arg->previous(), "%type%|*|& %type% [,)]") &&
enumValues.find(arg->str()) != enumValues.end()) {
if (executableScope && Token::Match(arg->previous(), "[*&]"))
// is this a variable declaration
const Token *prev = arg;
while (Token::Match(prev,"%type%|*|&"))
prev = prev->previous();
if (!Token::Match(prev,"[,(] %type%"))
continue;
if (prev->str() == "(" && (!Token::Match(prev->tokAt(-2), "%type%|::|*|& %type% (") || prev->strAt(-2) == "else"))
continue;
shadowArg.insert(arg->str());
if (inScope && _settings->isEnabled("style")) {