speedup: made the token simplifications a little faster
This commit is contained in:
parent
7a8b980627
commit
96ebf343f1
|
@ -393,27 +393,29 @@ void Tokenizer::tokenize(std::istream &code, const char FileName[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef..
|
// typedef..
|
||||||
for (Token *tok = _tokens; tok;)
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if (Token::Match(tok, "typedef %type% %type% ;"))
|
if (tok->str() != "typedef")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Token::Match(tok->next(), "%type% %type% ;"))
|
||||||
{
|
{
|
||||||
const char *type1 = tok->strAt(1);
|
const char *type1 = tok->strAt(1);
|
||||||
const char *type2 = tok->strAt(2);
|
const char *type2 = tok->strAt(2);
|
||||||
tok = const_cast<Token*>(tok->tokAt(4));
|
tok = const_cast<Token*>(tok->tokAt(3));
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
if (tok2->str() == type2)
|
if (tok2->str() == type2)
|
||||||
tok2->str(type1);
|
tok2->str(type1);
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Token::Match(tok, "typedef %type% %type% %type% ;"))
|
else if (Token::Match(tok->next(), "%type% %type% %type% ;"))
|
||||||
{
|
{
|
||||||
const char *type1 = tok->strAt(1);
|
const char *type1 = tok->strAt(1);
|
||||||
const char *type2 = tok->strAt(2);
|
const char *type2 = tok->strAt(2);
|
||||||
const char *type3 = tok->strAt(3);
|
const char *type3 = tok->strAt(3);
|
||||||
tok = const_cast<Token*>(tok->tokAt(5));
|
tok = const_cast<Token*>(tok->tokAt(4));
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
if (tok2->str() == type3)
|
if (tok2->str() == type3)
|
||||||
|
@ -423,10 +425,7 @@ void Tokenizer::tokenize(std::istream &code, const char FileName[])
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tok = tok->next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove __asm..
|
// Remove __asm..
|
||||||
|
@ -448,29 +447,14 @@ void Tokenizer::tokenize(std::istream &code, const char FileName[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove "volatile"
|
// Remove "volatile" and "mutable"
|
||||||
while (Token::simpleMatch(_tokens, "volatile"))
|
while (_tokens && (_tokens->str() == "volatile" || _tokens->str() == "mutable"))
|
||||||
{
|
{
|
||||||
_tokens->deleteThis();
|
_tokens->deleteThis();
|
||||||
}
|
}
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
while (Token::simpleMatch(tok->next(), "volatile"))
|
while (tok->next() && (tok->next()->str() == "volatile" || tok->next()->str() == "mutable"))
|
||||||
{
|
|
||||||
tok->deleteNext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove "mutable"
|
|
||||||
while (Token::simpleMatch(_tokens, "mutable"))
|
|
||||||
{
|
|
||||||
Token *tok = _tokens;
|
|
||||||
_tokens = _tokens->next();
|
|
||||||
delete tok;
|
|
||||||
}
|
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
|
||||||
{
|
|
||||||
while (Token::simpleMatch(tok->next(), "mutable"))
|
|
||||||
{
|
{
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue