Optimization: Improved performance of simplifyTypedef for code with lots of typedefs
20% performance gain when checking ExtremeTuxRacer sourcecode (with glext.h available)
This commit is contained in:
parent
e9318d7bfc
commit
d6390dbd14
|
@ -747,33 +747,17 @@ void Tokenizer::simplifyTypedef()
|
||||||
if (!tokOffset)
|
if (!tokOffset)
|
||||||
syntaxError(tok);
|
syntaxError(tok);
|
||||||
|
|
||||||
if (Token::Match(tokOffset, "%type%")) {
|
if (tokOffset->isName() && !tokOffset->isKeyword()) {
|
||||||
// found the type name
|
// found the type name
|
||||||
typeName = tokOffset;
|
typeName = tokOffset;
|
||||||
tokOffset = tokOffset->next();
|
tokOffset = tokOffset->next();
|
||||||
|
|
||||||
// check for array
|
// check for array
|
||||||
if (tokOffset && tokOffset->str() == "[") {
|
while (tokOffset && tokOffset->str() == "[") {
|
||||||
arrayStart = tokOffset;
|
if (!arrayStart)
|
||||||
|
arrayStart = tokOffset;
|
||||||
bool atEnd = false;
|
arrayEnd = tokOffset->link();
|
||||||
while (!atEnd) {
|
tokOffset = arrayEnd->next();
|
||||||
while (tokOffset->next() && !Token::Match(tokOffset->next(), ";|,")) {
|
|
||||||
tokOffset = tokOffset->next();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tokOffset->next())
|
|
||||||
return; // invalid input
|
|
||||||
else if (tokOffset->next()->str() == ";")
|
|
||||||
atEnd = true;
|
|
||||||
else if (tokOffset->str() == "]")
|
|
||||||
atEnd = true;
|
|
||||||
else
|
|
||||||
tokOffset = tokOffset->next();
|
|
||||||
}
|
|
||||||
|
|
||||||
arrayEnd = tokOffset;
|
|
||||||
tokOffset = tokOffset->next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for end or another
|
// check for end or another
|
||||||
|
@ -1134,8 +1118,9 @@ void Tokenizer::simplifyTypedef()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for typedef that can be substituted
|
// check for typedef that can be substituted
|
||||||
else if (Token::simpleMatch(tok2, pattern.c_str()) ||
|
else if (tok2->isNameOnly() &&
|
||||||
(inMemberFunc && tok2->str() == typeName->str())) {
|
(Token::simpleMatch(tok2, pattern.c_str()) ||
|
||||||
|
(inMemberFunc && tok2->str() == typeName->str()))) {
|
||||||
// member function class variables don't need qualification
|
// member function class variables don't need qualification
|
||||||
if (!(inMemberFunc && tok2->str() == typeName->str()) && pattern.find("::") != std::string::npos) { // has a "something ::"
|
if (!(inMemberFunc && tok2->str() == typeName->str()) && pattern.find("::") != std::string::npos) { // has a "something ::"
|
||||||
Token *start = tok2;
|
Token *start = tok2;
|
||||||
|
|
|
@ -2896,7 +2896,7 @@ private:
|
||||||
"struct S {\n"
|
"struct S {\n"
|
||||||
" _Atomic union { int n; };\n"
|
" _Atomic union { int n; };\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (debug) Failed to parse 'typedef _Atomic ( int ) & atomic_int_ref ;'. The checking continues anyway.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void symboldatabase35() { // ticket #4806 and #4841
|
void symboldatabase35() { // ticket #4806 and #4841
|
||||||
|
|
Loading…
Reference in New Issue