Adapt Tokenizer::simplifyCallingConvention() and Tokenizer::simplifyKeyword() for the match compiler
This little change gives another 6% speed improvement on my box. (tested with the testsuite and checking the 'rpm' codebase) The profiler showed we were spending quite some time in Tokenizer::simplifyCallingConvention(). The multi match pattern in there is "complex", at least for the on-the-fly parser.
This commit is contained in:
parent
5773e69ab1
commit
e22b1f7740
|
@ -8459,9 +8459,8 @@ void Tokenizer::simplifyStructDecl()
|
|||
|
||||
void Tokenizer::simplifyCallingConvention()
|
||||
{
|
||||
static const char pattern[] = "__cdecl|__stdcall|__fastcall|__thiscall|__clrcall|__syscall|__pascal|__fortran|__far|__near|WINAPI|APIENTRY|CALLBACK";
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
while (Token::Match(tok, pattern)) {
|
||||
while (Token::Match(tok, "__cdecl|__stdcall|__fastcall|__thiscall|__clrcall|__syscall|__pascal|__fortran|__far|__near|WINAPI|APIENTRY|CALLBACK")) {
|
||||
tok->deleteThis();
|
||||
}
|
||||
}
|
||||
|
@ -8505,17 +8504,27 @@ void Tokenizer::simplifyAttribute()
|
|||
// - Not in C++ standard yet
|
||||
void Tokenizer::simplifyKeyword()
|
||||
{
|
||||
std::string pattern = "volatile|inline|__inline|__forceinline|register|__restrict|__restrict__";
|
||||
if (_settings->standards.c >= Standards::C99)
|
||||
pattern += "|restrict";
|
||||
if (_settings->standards.cpp >= Standards::CPP11)
|
||||
pattern += "|constexpr|override|final";
|
||||
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
while (Token::Match(tok, pattern.c_str())) {
|
||||
while (Token::Match(tok, "volatile|inline|__inline|__forceinline|register|__restrict|__restrict__")) {
|
||||
tok->deleteThis();
|
||||
}
|
||||
}
|
||||
|
||||
if (_settings->standards.c >= Standards::C99) {
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
while (Token::Match(tok, "restrict")) {
|
||||
tok->deleteThis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_settings->standards.cpp >= Standards::CPP11) {
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
while (Token::Match(tok, "constexpr|override|final")) {
|
||||
tok->deleteThis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyAssignmentInFunctionCall()
|
||||
|
|
Loading…
Reference in New Issue