From fa5cdcb12831231c650e9b82e613bd296f5024a1 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Mon, 1 Jun 2009 16:27:04 +0700 Subject: [PATCH] Tokenizer::simplifyTokenList: reduce indent. No functional change. --- src/tokenize.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/tokenize.cpp b/src/tokenize.cpp index 6a762b3f4..11d14ffc6 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -1151,30 +1151,32 @@ void Tokenizer::simplifyTokenList() } - // Replace 'sizeof(var)'.. + // Replace 'sizeof(var)' with 'sizeof(type)' for (Token *tok = _tokens; tok; tok = tok->next()) { - if (Token::Match(tok, "[;{}] %type% %var% ;") && tok->tokAt(2)->varId() > 0) - { - const unsigned int varid = tok->tokAt(2)->varId(); + if (! Token::Match(tok, "[;{}] %type% %var% ;")) + continue; - // Replace 'sizeof(var)' with 'sizeof(type)' - int indentlevel = 0; - for (Token *tok2 = tok; tok2; tok2 = tok2->next()) + if (tok->tokAt(2)->varId() <= 0) + continue; + + const unsigned int varid = tok->tokAt(2)->varId(); + + int indentlevel = 0; + for (Token *tok2 = tok; tok2; tok2 = tok2->next()) + { + if (tok2->str() == "{") + ++indentlevel; + else if (tok2->str() == "}") { - if (tok2->str() == "{") - ++indentlevel; - else if (tok2->str() == "}") - { - --indentlevel; - if (indentlevel < 0) - break; - } - else if (Token::Match(tok2, "sizeof ( %varid% )", varid)) - { - tok2 = tok2->tokAt(2); - tok2->str(tok->strAt(1)); - } + --indentlevel; + if (indentlevel < 0) + break; + } + else if (Token::Match(tok2, "sizeof ( %varid% )", varid)) + { + tok2 = tok2->tokAt(2); + tok2->str(tok->strAt(1)); } } }