From e8b8cfec7841af2ec3908247ab36e0a36ce82137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Thu, 28 Jan 2021 22:18:17 +0100 Subject: [PATCH] some minor optimizations (#3057) --- lib/library.cpp | 4 ++-- lib/library.h | 2 +- lib/tokenize.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/library.cpp b/lib/library.cpp index 154ab8ee2..be138e7a0 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -1414,7 +1414,7 @@ bool Library::isnoreturn(const Token *ftok) const return true; if (isNotLibraryFunction(ftok)) return false; - const std::map::const_iterator it = mNoReturn.find(getFunctionName(ftok)); + const std::unordered_map::const_iterator it = mNoReturn.find(getFunctionName(ftok)); if (it == mNoReturn.end()) return false; if (it->second == FalseTrueMaybe::Maybe) @@ -1428,7 +1428,7 @@ bool Library::isnotnoreturn(const Token *ftok) const return false; if (isNotLibraryFunction(ftok)) return false; - const std::map::const_iterator it = mNoReturn.find(getFunctionName(ftok)); + const std::unordered_map::const_iterator it = mNoReturn.find(getFunctionName(ftok)); if (it == mNoReturn.end()) return false; if (it->second == FalseTrueMaybe::Maybe) diff --git a/lib/library.h b/lib/library.h index f8c983542..6456e3699 100644 --- a/lib/library.h +++ b/lib/library.h @@ -564,7 +564,7 @@ private: std::map mAlloc; // allocation functions std::map mDealloc; // deallocation functions std::map mRealloc; // reallocation functions - std::map mNoReturn; // is function noreturn? + std::unordered_map mNoReturn; // is function noreturn? std::map mReturnValue; std::map mReturnValueType; std::map mReturnValueContainer; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c611890f3..aa299cd3a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7381,7 +7381,7 @@ void Tokenizer::simplifyVariableMultipleAssign() } // Binary operators simplification map -static const std::map cAlternativeTokens = { +static const std::unordered_map cAlternativeTokens = { std::make_pair("and", "&&") , std::make_pair("and_eq", "&=") , std::make_pair("bitand", "&") @@ -7437,7 +7437,7 @@ bool Tokenizer::simplifyCAlternativeTokens() if (!tok->isName()) continue; - const std::map::const_iterator cOpIt = cAlternativeTokens.find(tok->str()); + const std::unordered_map::const_iterator cOpIt = cAlternativeTokens.find(tok->str()); if (cOpIt != cAlternativeTokens.end()) { alt.push_back(tok); @@ -7474,7 +7474,7 @@ bool Tokenizer::simplifyCAlternativeTokens() return false; for (Token *tok: alt) { - const std::map::const_iterator cOpIt = cAlternativeTokens.find(tok->str()); + const std::unordered_map::const_iterator cOpIt = cAlternativeTokens.find(tok->str()); if (cOpIt != cAlternativeTokens.end()) tok->str(cOpIt->second); else if (tok->str() == "not")