Skip to content

Commit 9480f96

Browse files
committed
Token: only look up control-flow keywords in update_property_info() if necessary
1 parent ec57b66 commit 9480f96

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/token.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static const std::unordered_set<std::string> controlFlowKeywords = {
107107

108108
void Token::update_property_info()
109109
{
110-
setFlag(fIsControlFlowKeyword, controlFlowKeywords.find(mStr) != controlFlowKeywords.end());
110+
setFlag(fIsControlFlowKeyword, false);
111111
// TODO: clear fIsLong
112112
isStandardType(false);
113113

@@ -125,8 +125,13 @@ void Token::update_property_info()
125125
else if (std::isalpha((unsigned char)mStr[0]) || mStr[0] == '_' || mStr[0] == '$') { // Name
126126
if (mImpl->mVarId)
127127
tokType(eVariable);
128-
else if (mTokensFrontBack.list.isKeyword(mStr) || mStr == "asm") // TODO: not a keyword
128+
else if (mTokensFrontBack.list.isKeyword(mStr)) {
129129
tokType(eKeyword);
130+
setFlag(fIsControlFlowKeyword, controlFlowKeywords.find(mStr) != controlFlowKeywords.end());
131+
}
132+
else if (mStr == "asm") { // TODO: not a keyword
133+
tokType(eKeyword);
134+
}
130135
// TODO: remove condition? appears to be (no longer necessary) protection for reset of varids in Tokenizer::setVarId()
131136
else if (mTokType != eVariable && mTokType != eFunction && mTokType != eType && mTokType != eKeyword)
132137
tokType(eName);

0 commit comments

Comments
 (0)