From 8950beac3786c6a3fa0f0bfa73a30edc45f3c519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 23 Sep 2010 21:40:08 +0200 Subject: [PATCH] Optimisation to make the CheckUninitVar::parse slightly faster --- lib/checkother.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index abc4c82cc..c5be20fe6 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3189,7 +3189,7 @@ private: return &tok; } - if (Token::Match(tok.previous(), "[;{}] %var% =|[|.")) + if (Token::Match(tok.previous(), "[;{}] %var% [=[.]")) { if (tok.next()->str() == ".") { @@ -3203,7 +3203,7 @@ private: // check variable usages in rhs/index for (const Token *tok2 = tok.tokAt(2); tok2; tok2 = tok2->next()) { - if (Token::Match(tok2, ";|)|=|?")) + if (Token::Match(tok2, "[;)=?]")) break; if (Token::Match(tok2, "%var% (")) break; @@ -3307,7 +3307,7 @@ private: } } - if (Token::Match(&tok, "%var% (") && uvarFunctions.find(tok.str()) == uvarFunctions.end()) + else if (Token::Match(&tok, "%var% (") && uvarFunctions.find(tok.str()) == uvarFunctions.end()) { if (Token::simpleMatch(&tok, "sizeof (")) return tok.next()->link(); @@ -3480,10 +3480,6 @@ private: const unsigned int varid2 = tok.tokAt(-2)->varId(); if (varid2) { - /* - const Token *tok2 = Token::findmatch(owner->_tokenizer->tokens(), "%varid%", varid2); - if (tok2 && !Token::simpleMatch(tok2->previous(), "*")) - */ { use(checks, &tok); return &tok;