Skip to content

Commit

Permalink
Tokenizer: reduced isCPP() calls in simplifyTypedefCpp()
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Jun 1, 2024
1 parent 4809f26 commit 2f93fca
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ void Tokenizer::simplifyTypedef()

void Tokenizer::simplifyTypedefCpp()
{
const bool cpp = isCPP();
bool isNamespace = false;
std::string className, fullClassName;
bool hasClass = false;
Expand Down Expand Up @@ -1714,7 +1715,7 @@ void Tokenizer::simplifyTypedefCpp()
}

// check for member functions
else if (tok2->isCpp() && tok2->str() == "(" && isFunctionHead(tok2, "{:")) {
else if (cpp && tok2->str() == "(" && isFunctionHead(tok2, "{:")) {
const Token *func = tok2->previous();

/** @todo add support for multi-token operators */
Expand All @@ -1741,7 +1742,7 @@ void Tokenizer::simplifyTypedefCpp()
// check for entering a new scope
else if (tok2->str() == "{") {
// check for entering a new namespace
if (tok2->isCpp()) {
if (cpp) {
if (tok2->strAt(-2) == "namespace") {
if (classLevel < spaceInfo.size() &&
spaceInfo[classLevel].isNamespace &&
Expand Down Expand Up @@ -1770,7 +1771,7 @@ void Tokenizer::simplifyTypedefCpp()

// check for operator typedef
/** @todo add support for multi-token operators */
else if (tok2->isCpp() &&
else if (cpp &&
tok2->str() == "operator" &&
tok2->next() &&
tok2->next()->str() == typeName->str() &&
Expand Down

0 comments on commit 2f93fca

Please sign in to comment.