Skip to content

Commit 5885988

Browse files
committed
Cache and reuse value
1 parent aece225 commit 5885988

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/checkclass.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,11 +1245,12 @@ void CheckClass::operatorEq()
12451245
}
12461246
if (!returnSelfRef) {
12471247
// make sure we really have a copy assignment operator
1248-
if (Token::Match(func->tokenDef->tokAt(2), "const| %name% &")) {
1249-
if (func->tokenDef->strAt(2) == "const" &&
1250-
func->tokenDef->strAt(3) == scope->className)
1248+
const Token *paramTok = func->tokenDef->tokAt(2);
1249+
if (Token::Match(paramTok, "const| %name% &")) {
1250+
if (paramTok->str() == "const" &&
1251+
paramTok->strAt(1) == scope->className)
12511252
operatorEqReturnError(func->retDef, scope->className);
1252-
else if (func->tokenDef->strAt(2) == scope->className)
1253+
else if (paramTok->str() == scope->className)
12531254
operatorEqReturnError(func->retDef, scope->className);
12541255
}
12551256
}

0 commit comments

Comments
 (0)