From c05e632bafbf8c097f396b0f6def5c618330c948 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Tue, 3 Feb 2015 11:00:40 +0300 Subject: [PATCH] Cache and reuse value --- lib/valueflow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index b6e80a50d..9194186e1 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1645,8 +1645,9 @@ static void valueFlowFunctionDefaultParameter(TokenList *tokenlist, SymbolDataba for (std::size_t arg = function->minArgCount(); arg < function->argCount(); arg++) { const Variable* var = function->getArgumentVar(arg); if (var && var->hasDefault() && Token::Match(var->nameToken(), "%var% = %num%|%str% [,)]")) { - const_cast(var->nameToken()->tokAt(2))->values.front().defaultArg = true; - valueFlowInjectParameter(tokenlist, errorLogger, settings, var, scope, var->nameToken()->tokAt(2)->values); + const Token* valueTok = var->nameToken()->tokAt(2); + const_cast(valueTok)->values.front().defaultArg = true; + valueFlowInjectParameter(tokenlist, errorLogger, settings, var, scope, valueTok->values); } } }