From b20f87faf2d9686737f0853b3b07dc9bc14eed34 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 25 Jun 2014 20:41:22 +0200 Subject: [PATCH] Optimized Tokenizer::simplifyPlatformTypes() once more: Another 3% improvement on Windows. -> All Token::Match strings are uppercase, so check Token::isUpperCaseName() to avoid comparisons with very slow long Token::Match strings (idea from amai) Removed duplicate Token::Match call in symboldatabase.cpp --- lib/symboldatabase.cpp | 16 +++++++++------- lib/tokenize.cpp | 5 ++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 4c92fbc58..fa84098a0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2394,13 +2394,15 @@ void Scope::getVariableList() continue; } else break; - } else if (Token::Match(tok, "struct|union {") && Token::Match(tok->next()->link(), "} %var% ;|[")) { - tok = tok->next()->link()->tokAt(2); - continue; - } else if (Token::Match(tok, "struct|union {") && Token::simpleMatch(tok->next()->link(), "} ;")) { - level++; - tok = tok->next(); - continue; + } else if (Token::Match(tok, "struct|union {")) { + if (Token::Match(tok->next()->link(), "} %var% ;|[")) { + tok = tok->next()->link()->tokAt(2); + continue; + } else if (Token::simpleMatch(tok->next()->link(), "} ;")) { + level++; + tok = tok->next(); + continue; + } } // Borland C++: Skip all variables in the __published section. diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c912f1e3c..992449e39 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5441,8 +5441,11 @@ void Tokenizer::simplifyPlatformTypes() _settings->platformType == Settings::Win32W || _settings->platformType == Settings::Win64) { for (Token *tok = list.front(); tok; tok = tok->next()) { - if (!tok->isName()) + if (tok->type() != Token::eType && tok->type() != Token::eName) continue; + if (!tok->isUpperCaseName()) // All WinAPI types are uppercase. Reduce number of Token::Match calls by this condition. + continue; + if (Token::Match(tok, "BOOL|INT|INT32|HFILE|LONG32")) { tok->originalName(tok->str()); tok->str("int");