aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Komissarov <ABBAPOH@gmail.com>2019-11-24 16:44:20 +0900
committerIvan Komissarov <ABBAPOH@gmail.com>2019-12-02 13:45:19 +0000
commita8198cce40983d2e3d9385bb7cbc492ea9196026 (patch)
treef33915684717eb4744a64395e0886573778d8429
parent7606963ffd637aa4a410f931621af3bb982899b7 (diff)
Fix 'modernize-use-emplace' warnings
std::vector::emplace_back creates an object in a vector and allows to avoid creating temporary object that is than moved into a vector. This simplifies code a bit as it is not necessary to call std::make_pair or use uniform initialization to create a temporary object Change-Id: I0c5500a818f78d07bc753e25f529c06762cb615c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/lib/corelib/api/project.cpp2
-rw-r--r--src/lib/corelib/buildgraph/inputartifactscanner.cpp2
-rw-r--r--src/lib/corelib/buildgraph/qtmocscanner.cpp2
-rw-r--r--src/lib/corelib/buildgraph/rulenode.cpp2
-rw-r--r--src/lib/corelib/buildgraph/rulesapplicator.cpp6
-rw-r--r--src/lib/corelib/language/language.cpp4
-rw-r--r--src/lib/corelib/language/moduleloader.cpp4
-rw-r--r--src/lib/corelib/language/projectresolver.cpp2
-rw-r--r--src/lib/corelib/tools/shellutils.cpp4
-rw-r--r--src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.cpp2
10 files changed, 15 insertions, 15 deletions
diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp
index bff79bdfa..383ce6ab5 100644
--- a/src/lib/corelib/api/project.cpp
+++ b/src/lib/corelib/api/project.cpp
@@ -1216,7 +1216,7 @@ Project::BuildGraphInfo Project::getBuildGraphInfo(const QString &bgFilePath,
for (const QString &prop : requestedProperties) {
QStringList components = prop.split(QLatin1Char('.'));
const QString propName = components.takeLast();
- props.push_back(std::make_pair(components.join(QLatin1Char('.')), propName));
+ props.emplace_back(components.join(QLatin1Char('.')), propName);
}
for (const ResolvedProductConstPtr &product : project->allProducts()) {
if (props.empty())
diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp
index ae7d456cf..14f39bb2a 100644
--- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp
+++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp
@@ -372,7 +372,7 @@ void InputArtifactScanner::scanWithScannerPlugin(DependencyScanner *scanner,
const QStringList &dependencies = scanner->collectDependencies(
inputArtifact, fileToBeScanned, m_fileTagsForScanner.constData());
for (const QString &s : dependencies)
- scanResult->deps.push_back(RawScannedDependency(s));
+ scanResult->deps.emplace_back(s);
}
InputArtifactScannerContext::DependencyScannerCacheItem::DependencyScannerCacheItem() : valid(false)
diff --git a/src/lib/corelib/buildgraph/qtmocscanner.cpp b/src/lib/corelib/buildgraph/qtmocscanner.cpp
index c834c60e6..4e054a636 100644
--- a/src/lib/corelib/buildgraph/qtmocscanner.cpp
+++ b/src/lib/corelib/buildgraph/qtmocscanner.cpp
@@ -167,7 +167,7 @@ static RawScanResult runScanner(ScannerPlugin *scanner, const Artifact *artifact
if (FileInfo::exists(localFilePath))
includedFilePath = localFilePath;
}
- scanData.rawScanResult.deps.push_back(RawScannedDependency(includedFilePath));
+ scanData.rawScanResult.deps.emplace_back(includedFilePath);
}
scanner->close(opaq);
diff --git a/src/lib/corelib/buildgraph/rulenode.cpp b/src/lib/corelib/buildgraph/rulenode.cpp
index 7f77f1303..48d17934f 100644
--- a/src/lib/corelib/buildgraph/rulenode.cpp
+++ b/src/lib/corelib/buildgraph/rulenode.cpp
@@ -178,7 +178,7 @@ void RuleNode::apply(const Logger &logger,
if (removedInputForcesOutputRemoval)
outputArtifactsToRemove += parent;
else
- connectionsToBreak.push_back(std::make_pair(parent, artifact));
+ connectionsToBreak.emplace_back(parent, artifact);
}
disconnect(this, artifact);
}
diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp
index 16aa0c001..437e3f4da 100644
--- a/src/lib/corelib/buildgraph/rulesapplicator.cpp
+++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp
@@ -219,7 +219,7 @@ void RulesApplicator::doApply(const ArtifactSet &inputArtifacts, QScriptValue &p
if (!outputInfo.artifact)
continue;
outputArtifacts.push_back(outputInfo.artifact);
- ruleArtifactArtifactMap.push_back({ ruleArtifact.get(), outputInfo });
+ ruleArtifactArtifactMap.emplace_back(ruleArtifact.get(), outputInfo);
}
if (m_rule->artifacts.empty()) {
outputArtifacts.push_back(createOutputArtifactFromRuleArtifact(
@@ -287,7 +287,7 @@ void RulesApplicator::doApply(const ArtifactSet &inputArtifacts, QScriptValue &p
}
const QVariant value = scriptValue.toVariant();
setConfigProperty(artifactModulesCfg, binding.name, value);
- outputArtifact->pureProperties.push_back(std::make_pair(binding.name, value));
+ outputArtifact->pureProperties.emplace_back(binding.name, value);
}
outputArtifact->properties->setValue(artifactModulesCfg);
if (!outputInfo.newlyCreated && (outputArtifact->fileTags() != outputInfo.oldFileTags
@@ -607,7 +607,7 @@ public:
for (const auto &e : m_propertyValues) {
const QStringList key{e.module, e.name};
setConfigProperty(artifactCfg, key, e.value);
- outputArtifact->pureProperties.push_back(std::make_pair(key, e.value));
+ outputArtifact->pureProperties.emplace_back(key, e.value);
}
outputArtifact->properties->setValue(artifactCfg);
}
diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp
index 8608e08c7..3a08c089b 100644
--- a/src/lib/corelib/language/language.cpp
+++ b/src/lib/corelib/language/language.cpp
@@ -755,7 +755,7 @@ void SourceWildCards::expandPatterns(Set<QString> &result, const GroupConstPtr &
if (baseDir.startsWith(buildDir))
return;
- dirTimeStamps.push_back({ baseDir, FileInfo(baseDir).lastModified() });
+ dirTimeStamps.emplace_back(baseDir, FileInfo(baseDir).lastModified());
QStringList changed_parts = parts;
bool recursive = false;
@@ -800,7 +800,7 @@ void SourceWildCards::expandPatterns(Set<QString> &result, const GroupConstPtr &
expandPatterns(result, group, changed_parts, filePath, buildDir);
} else {
if (parentDir != baseDir)
- dirTimeStamps.push_back({parentDir, FileInfo(baseDir).lastModified()});
+ dirTimeStamps.emplace_back(parentDir, FileInfo(baseDir).lastModified());
result += QDir::cleanPath(filePath);
}
}
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index 1aeca0411..ed507b990 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -3228,7 +3228,7 @@ Item *ModuleLoader::getModulePrototype(ProductContext *productContext,
}
}
Item * const module = loadItemFromFile(filePath, CodeLocation());
- prototypeList.push_back(std::make_pair(module, productContext->profileName));
+ prototypeList.emplace_back(module, productContext->profileName);
if (module->type() != ItemType::Module) {
qCDebug(lcModuleLoader).nospace()
<< "Alleged module " << fullModuleName << " has type '"
@@ -3328,7 +3328,7 @@ static std::vector<std::pair<QualifiedId, ItemValuePtr>> instanceItemProperties(
if (itemValue->item()->type() == ItemType::ModulePrefix)
f(itemValue->item());
else
- result.push_back(std::make_pair(name, itemValue));
+ result.emplace_back(name, itemValue);
name.removeLast();
}
};
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index 6b678cb8f..d5b84af16 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -987,7 +987,7 @@ void ProjectResolver::resolveShadowProduct(Item *item, ProjectResolver::ProjectC
try {
adaptExportedPropertyValues(item);
} catch (const ErrorInfo &) {}
- m_productExportInfo.push_back(std::make_pair(m_productContext->product, item));
+ m_productExportInfo.emplace_back(m_productContext->product, item);
}
void ProjectResolver::setupExportedProperties(const Item *item, const QString &namePrefix,
diff --git a/src/lib/corelib/tools/shellutils.cpp b/src/lib/corelib/tools/shellutils.cpp
index 01c177cce..dae98f337 100644
--- a/src/lib/corelib/tools/shellutils.cpp
+++ b/src/lib/corelib/tools/shellutils.cpp
@@ -205,12 +205,12 @@ void CommandLine::setProgram(const std::string &program, bool raw)
void CommandLine::appendArgument(const QString &value)
{
- m_arguments.push_back(value);
+ m_arguments.emplace_back(value);
}
void CommandLine::appendArgument(const std::string &value)
{
- m_arguments.push_back(QString::fromStdString(value));
+ m_arguments.emplace_back(QString::fromStdString(value));
}
void CommandLine::appendArguments(const QList<QString> &args)
diff --git a/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.cpp b/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.cpp
index b882991d4..5cbb0cd61 100644
--- a/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.cpp
+++ b/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.cpp
@@ -80,7 +80,7 @@ std::vector<std::pair<QString, QString> > VisualStudioSolutionGlobalSection::pro
void VisualStudioSolutionGlobalSection::appendProperty(const QString &key, const QString &value)
{
- d->properties.push_back({ key, value });
+ d->properties.emplace_back(key, value);
}
} // namespace qbs