Patch from Dmitry-Me: reorder checks so that cheaper ones go first, reuse previously computed values, return early on edge condition
This commit is contained in:
parent
c61d2b9f41
commit
2e3f26ba58
|
@ -7316,8 +7316,9 @@ void Tokenizer::simplifyEnum()
|
||||||
tok = tok->previous();
|
tok = tok->previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "class|struct|namespace") && tok->next() &&
|
if (tok && tok->next() &&
|
||||||
(!tok->previous() || (tok->previous() && tok->previous()->str() != "enum"))) {
|
(!tok->previous() || (tok->previous()->str() != "enum")) &&
|
||||||
|
Token::Match(tok, "class|struct|namespace")) {
|
||||||
className = tok->next()->str();
|
className = tok->next()->str();
|
||||||
classLevel = 0;
|
classLevel = 0;
|
||||||
} else if (tok->str() == "}") {
|
} else if (tok->str() == "}") {
|
||||||
|
@ -7347,8 +7348,8 @@ void Tokenizer::simplifyEnum()
|
||||||
|
|
||||||
// check for name
|
// check for name
|
||||||
if (tok->next()->isName()) {
|
if (tok->next()->isName()) {
|
||||||
enumType = tok->next();
|
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
enumType = tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for C++0x typed enumeration
|
// check for C++0x typed enumeration
|
||||||
|
@ -7360,8 +7361,8 @@ void Tokenizer::simplifyEnum()
|
||||||
return; // can't recover
|
return; // can't recover
|
||||||
}
|
}
|
||||||
|
|
||||||
typeTokenStart = tok->next();
|
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
typeTokenStart = tok;
|
||||||
typeTokenEnd = typeTokenStart;
|
typeTokenEnd = typeTokenStart;
|
||||||
|
|
||||||
while (typeTokenEnd->next() && (typeTokenEnd->next()->str() == "::" ||
|
while (typeTokenEnd->next() && (typeTokenEnd->next()->str() == "::" ||
|
||||||
|
@ -7504,6 +7505,9 @@ void Tokenizer::simplifyEnum()
|
||||||
|
|
||||||
// Substitute enum values
|
// Substitute enum values
|
||||||
{
|
{
|
||||||
|
if (!tok1)
|
||||||
|
return;
|
||||||
|
|
||||||
if (_settings->terminated())
|
if (_settings->terminated())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -7520,8 +7524,6 @@ void Tokenizer::simplifyEnum()
|
||||||
bool simplify = false;
|
bool simplify = false;
|
||||||
EnumValue *ev = nullptr;
|
EnumValue *ev = nullptr;
|
||||||
|
|
||||||
if (!tok1)
|
|
||||||
return;
|
|
||||||
for (Token *tok2 = tok1->next(); tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = tok1->next(); tok2; tok2 = tok2->next()) {
|
||||||
if (tok2->str() == "}") {
|
if (tok2->str() == "}") {
|
||||||
--level;
|
--level;
|
||||||
|
|
|
@ -1324,7 +1324,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t n, typename T>
|
template<size_t n, typename T>
|
||||||
size_t getArraylength( const T(&)[n]) {
|
size_t getArraylength(const T(&)[n]) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue