Optimized Tokenizer::simplifyPlatformTypes() once more: Another 3% improvement on Windows.

-> All Token::Match strings are uppercase, so check Token::isUpperCaseName() to avoid comparisons with very slow long Token::Match strings (idea from amai)
Removed duplicate Token::Match call in symboldatabase.cpp
This commit is contained in:
PKEuS 2014-06-25 20:41:22 +02:00
parent 360fd4a565
commit b20f87faf2
2 changed files with 13 additions and 8 deletions

View File

@ -2394,14 +2394,16 @@ void Scope::getVariableList()
continue; continue;
} else } else
break; break;
} else if (Token::Match(tok, "struct|union {") && Token::Match(tok->next()->link(), "} %var% ;|[")) { } else if (Token::Match(tok, "struct|union {")) {
if (Token::Match(tok->next()->link(), "} %var% ;|[")) {
tok = tok->next()->link()->tokAt(2); tok = tok->next()->link()->tokAt(2);
continue; continue;
} else if (Token::Match(tok, "struct|union {") && Token::simpleMatch(tok->next()->link(), "} ;")) { } else if (Token::simpleMatch(tok->next()->link(), "} ;")) {
level++; level++;
tok = tok->next(); tok = tok->next();
continue; continue;
} }
}
// Borland C++: Skip all variables in the __published section. // Borland C++: Skip all variables in the __published section.
// These are automatically initialized. // These are automatically initialized.

View File

@ -5441,8 +5441,11 @@ void Tokenizer::simplifyPlatformTypes()
_settings->platformType == Settings::Win32W || _settings->platformType == Settings::Win32W ||
_settings->platformType == Settings::Win64) { _settings->platformType == Settings::Win64) {
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
if (!tok->isName()) if (tok->type() != Token::eType && tok->type() != Token::eName)
continue; continue;
if (!tok->isUpperCaseName()) // All WinAPI types are uppercase. Reduce number of Token::Match calls by this condition.
continue;
if (Token::Match(tok, "BOOL|INT|INT32|HFILE|LONG32")) { if (Token::Match(tok, "BOOL|INT|INT32|HFILE|LONG32")) {
tok->originalName(tok->str()); tok->originalName(tok->str());
tok->str("int"); tok->str("int");