Cache and reuse value

This commit is contained in:
Dmitry-Me 2017-09-04 23:33:52 +03:00
parent aece2254d7
commit 5885988b1f
1 changed files with 5 additions and 4 deletions

View File

@ -1245,11 +1245,12 @@ void CheckClass::operatorEq()
} }
if (!returnSelfRef) { if (!returnSelfRef) {
// make sure we really have a copy assignment operator // make sure we really have a copy assignment operator
if (Token::Match(func->tokenDef->tokAt(2), "const| %name% &")) { const Token *paramTok = func->tokenDef->tokAt(2);
if (func->tokenDef->strAt(2) == "const" && if (Token::Match(paramTok, "const| %name% &")) {
func->tokenDef->strAt(3) == scope->className) if (paramTok->str() == "const" &&
paramTok->strAt(1) == scope->className)
operatorEqReturnError(func->retDef, scope->className); operatorEqReturnError(func->retDef, scope->className);
else if (func->tokenDef->strAt(2) == scope->className) else if (paramTok->str() == scope->className)
operatorEqReturnError(func->retDef, scope->className); operatorEqReturnError(func->retDef, scope->className);
} }
} }