some minor optimizations (#3057)

This commit is contained in:
Oliver Stöneberg 2021-01-28 22:18:17 +01:00 committed by GitHub
parent 0df10c3cb5
commit e8b8cfec78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -1414,7 +1414,7 @@ bool Library::isnoreturn(const Token *ftok) const
return true;
if (isNotLibraryFunction(ftok))
return false;
const std::map<std::string, FalseTrueMaybe>::const_iterator it = mNoReturn.find(getFunctionName(ftok));
const std::unordered_map<std::string, FalseTrueMaybe>::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<std::string, FalseTrueMaybe>::const_iterator it = mNoReturn.find(getFunctionName(ftok));
const std::unordered_map<std::string, FalseTrueMaybe>::const_iterator it = mNoReturn.find(getFunctionName(ftok));
if (it == mNoReturn.end())
return false;
if (it->second == FalseTrueMaybe::Maybe)

View File

@ -564,7 +564,7 @@ private:
std::map<std::string, AllocFunc> mAlloc; // allocation functions
std::map<std::string, AllocFunc> mDealloc; // deallocation functions
std::map<std::string, AllocFunc> mRealloc; // reallocation functions
std::map<std::string, FalseTrueMaybe> mNoReturn; // is function noreturn?
std::unordered_map<std::string, FalseTrueMaybe> mNoReturn; // is function noreturn?
std::map<std::string, std::string> mReturnValue;
std::map<std::string, std::string> mReturnValueType;
std::map<std::string, int> mReturnValueContainer;

View File

@ -7381,7 +7381,7 @@ void Tokenizer::simplifyVariableMultipleAssign()
}
// Binary operators simplification map
static const std::map<std::string, std::string> cAlternativeTokens = {
static const std::unordered_map<std::string, std::string> 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<std::string, std::string>::const_iterator cOpIt = cAlternativeTokens.find(tok->str());
const std::unordered_map<std::string, std::string>::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<std::string, std::string>::const_iterator cOpIt = cAlternativeTokens.find(tok->str());
const std::unordered_map<std::string, std::string>::const_iterator cOpIt = cAlternativeTokens.find(tok->str());
if (cOpIt != cAlternativeTokens.end())
tok->str(cOpIt->second);
else if (tok->str() == "not")