avoid unnecessary copies with `insert()` (#4323)

This commit is contained in:
Oliver Stöneberg 2022-08-07 19:31:16 +02:00 committed by GitHub
parent 078a6d7804
commit 156323c95e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -220,7 +220,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
undef = 2 + argv[i];
}
mSettings->userUndefs.insert(undef);
mSettings->userUndefs.insert(std::move(undef));
}
else if (std::strncmp(argv[i], "--addon=", 8) == 0)

View File

@ -277,7 +277,7 @@ bool ThreadHandler::needsReCheck(const QString &filename, std::set<QString> &mod
line.remove(i,line.length());
line = QFileInfo(filename).absolutePath() + "/" + line;
if (needsReCheck(line, modified, unmodified)) {
modified.insert(line);
modified.insert(std::move(line));
return true;
}
}

View File

@ -562,11 +562,11 @@ private:
class ExportedFunctions {
public:
void addPrefix(const std::string& prefix) {
mPrefixes.insert(prefix);
void addPrefix(std::string prefix) {
mPrefixes.insert(std::move(prefix));
}
void addSuffix(const std::string& suffix) {
mSuffixes.insert(suffix);
void addSuffix(std::string suffix) {
mSuffixes.insert(std::move(suffix));
}
bool isPrefix(const std::string& prefix) const {
return (mPrefixes.find(prefix) != mPrefixes.end());

View File

@ -525,7 +525,7 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
}
}
if (!elseError.empty())
ret.insert(elseError);
ret.insert(std::move(elseError));
}

View File

@ -1973,7 +1973,7 @@ namespace {
nameSpace += tok1->str();
tok1 = tok1->next();
}
(*scopeInfo)->usingNamespaces.insert(nameSpace);
(*scopeInfo)->usingNamespaces.insert(std::move(nameSpace));
}
// check for member function
else if (tok->str() == "{") {
@ -2066,7 +2066,7 @@ namespace {
}
}
}
baseTypes.insert(base);
baseTypes.insert(std::move(base));
} while (tok && !Token::Match(tok, ";|{"));
}
@ -3354,7 +3354,7 @@ void Tokenizer::calculateScopes()
}
if (!usingNamespaceName.empty())
usingNamespaceName.pop_back();
tok->scopeInfo()->usingNamespaces.insert(usingNamespaceName);
tok->scopeInfo()->usingNamespaces.insert(std::move(usingNamespaceName));
} else if (Token::Match(tok, "namespace|class|struct|union %name% {|::|:|<")) {
for (Token* nameTok = tok->next(); nameTok && !Token::Match(nameTok, "{|:"); nameTok = nameTok->next()) {
if (Token::Match(nameTok, ";|<")) {