Optimization: isNotPattern() removed

This commit is contained in:
Reijo Tomperi 2008-12-23 21:20:54 +00:00
parent d24913caf8
commit a303cf278d
2 changed files with 2 additions and 20 deletions

View File

@ -159,7 +159,7 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
if (!tok)
{
// If we have no tokens, pattern "!!else" should return true
if( isNotPattern( p ) )
if( p[1] == '!' && p[0] == '!' && strlen(p) > 2 )
return true;
else
return false;
@ -294,7 +294,7 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
}
// Parse "not" options. Token can be anything except the given one
else if( isNotPattern( str ) )
else if( str[1] == '!' && str[0] == '!' && strlen(str) > 2 )
{
if( strcmp( tok->aaaa(), &(str[2]) ) == 0 )
return false;
@ -310,14 +310,6 @@ bool TOKEN::Match(const TOKEN *tok, const char pattern[], const char *varname1[]
return true;
}
bool TOKEN::isNotPattern( const char *pattern )
{
if( pattern && strlen(pattern) > 2 && pattern[0] == '!' && pattern[1] == '!' )
return true;
else
return false;
}
bool TOKEN::isName() const
{
return _isName;

10
token.h
View File

@ -155,16 +155,6 @@ private:
void next( TOKEN *next );
void previous( TOKEN *previous );
/**
* Return true if pattern is e.g. "!!else".
* See Match() for more info.
*
* @param pattern Pattern to match, e.g. "if ; !!else"
* @return true if pattern starts with "!!" and contains 3
* or more characters.
*/
static bool isNotPattern( const char *pattern );
std::string _str;
char * _cstr;
bool _isName;