Minor optimizations: introduce use of simpleMatch, don't use [simple]Match on one word patterns;

Minor style formattings
This commit is contained in:
Nicolas Le Cam 2008-12-22 23:27:49 +00:00
parent d6ffc63230
commit 85239c48a9
1 changed files with 38 additions and 39 deletions

View File

@ -166,7 +166,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
// Loop..
if ( TOKEN::Match(tok, "for (") )
if ( TOKEN::simpleMatch(tok, "for (") )
{
const TOKEN *tok2 = tok->tokAt(2);
@ -191,9 +191,9 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
continue;
// Goto the end of the for loop..
while (tok2 && !TOKEN::Match(tok2,")"))
while ( tok && tok2->str() != ")" )
tok2 = tok2->next();
if (!tok2 || !(tok2->tokAt(5)))
if ( !tok2 || !tok2->tokAt(5) )
break;
std::ostringstream pattern;
@ -202,7 +202,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
int indentlevel2 = 0;
while ( (tok2 = tok2->next()) )
{
if ( (tok2->str() == ";") && indentlevel2 == 0 )
if ( tok2->str() == ";" && indentlevel2 == 0 )
break;
if ( tok2->str() == "{" )
@ -404,15 +404,14 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
{
const char declstruct[] = "struct|class %var% {";
for ( const TOKEN *tok = TOKEN::findmatch(_tokenizer->tokens(), declstruct);
tok;
tok = TOKEN::findmatch( tok->next(), declstruct ) )
tok; tok = TOKEN::findmatch(tok->next(), declstruct) )
{
const std::string &structname = tok->next()->str();
// Found a struct declaration. Search for arrays..
for ( const TOKEN * tok2 = tok->next()->next(); tok2; tok2 = tok2->next() )
for ( const TOKEN *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next() )
{
if ( TOKEN::Match(tok2, "}") )
if ( tok2->str() == "}" )
break;
int ivar = 0;
@ -436,7 +435,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
// Class member variable => Check functions
if ( TOKEN::Match(tok, "class") )
if ( tok->str() == "class" )
{
std::string func_pattern(structname + " :: %var% (");
const TOKEN *tok3 = TOKEN::findmatch(_tokenizer->tokens(), func_pattern.c_str());
@ -447,7 +446,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
if ( TOKEN::Match(tok4, "[;{}]") )
break;
if ( TOKEN::Match(tok4, ") {") )
if ( TOKEN::simpleMatch(tok4, ") {") )
{
const char *names[2] = {varname[1], 0};
CheckBufferOverrun_CheckScope(tok4->tokAt(2), names, arrsize, total_size, 0);
@ -480,18 +479,18 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
while ( tok3 )
{
// End of statement.
if ( TOKEN::Match(tok3, ";") )
if ( tok3->str() == ";" )
{
CheckTok = tok3;
break;
}
// End of function declaration..
if ( TOKEN::Match(tok3, ") ;") )
if ( TOKEN::simpleMatch(tok3, ") ;") )
break;
// Function implementation..
if ( TOKEN::Match(tok3, ") {") )
if ( TOKEN::simpleMatch(tok3, ") {") )
{
CheckTok = tok3->tokAt(2);
break;