From f0aa9e31de0fd37c062586ce37d9c4da491498ff Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Wed, 12 Aug 2015 10:57:36 +0300 Subject: [PATCH] Cache and reuse value --- lib/valueflow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7eb6e3549..239bdc184 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -2032,11 +2032,11 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol if (!Token::Match(scope->classDef, "switch ( %var% ) {")) continue; const Token *vartok = scope->classDef->tokAt(2); - if (!vartok->variable()) + const Variable *var = vartok->variable(); + if (!var) continue; // bailout: global non-const variables - const Variable *var = vartok->variable(); if (!(var->isLocal() || var->isArgument()) && !var->isConst()) { if (settings->debugwarnings) bailout(tokenlist, errorLogger, vartok, "switch variable " + var->name() + " is global");