summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Komissarov <abbapoh@gmail.com>2019-12-22 16:43:32 +0200
committerIvan Komissarov <ABBAPOH@gmail.com>2020-01-06 14:36:59 +0000
commita451ec700dc679348fcf63da7cfd93469cd736f0 (patch)
treecb48d1efc6a9ae1a3b5b8053f294bb1c04dc1acc
parentd870e416907263f5da437d1783bcda9f00fbe10e (diff)
downloadqbs-a451ec700dc679348fcf63da7cfd93469cd736f0.tar.gz
Replace QList<Internal::ResolvedProductPtr> with QVector
QList is inefficient with shared_ptr and results in an extra allocation per each element Change-Id: I5d5492d855a233e8aec3f09a67dd4b83fb0d2c13 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/lib/corelib/api/internaljobs.cpp7
-rw-r--r--src/lib/corelib/api/internaljobs.h12
-rw-r--r--src/lib/corelib/api/jobs.cpp7
-rw-r--r--src/lib/corelib/api/jobs.h7
-rw-r--r--src/lib/corelib/api/project.cpp25
-rw-r--r--src/lib/corelib/api/project_p.h12
-rw-r--r--src/lib/corelib/buildgraph/artifactcleaner.cpp2
-rw-r--r--src/lib/corelib/buildgraph/artifactcleaner.h2
-rw-r--r--src/lib/corelib/buildgraph/nodetreedumper.cpp2
-rw-r--r--src/lib/corelib/buildgraph/nodetreedumper.h2
-rw-r--r--src/lib/corelib/buildgraph/timestampsupdater.cpp2
-rw-r--r--src/lib/corelib/buildgraph/timestampsupdater.h2
12 files changed, 43 insertions, 39 deletions
diff --git a/src/lib/corelib/api/internaljobs.cpp b/src/lib/corelib/api/internaljobs.cpp
index 3b68e01b5..0f31148ba 100644
--- a/src/lib/corelib/api/internaljobs.cpp
+++ b/src/lib/corelib/api/internaljobs.cpp
@@ -351,7 +351,7 @@ BuildGraphTouchingJob::BuildGraphTouchingJob(const Logger &logger, QObject *pare
BuildGraphTouchingJob::~BuildGraphTouchingJob() = default;
void BuildGraphTouchingJob::setup(const TopLevelProjectPtr &project,
- const QList<ResolvedProductPtr> &products, bool dryRun)
+ const QVector<ResolvedProductPtr> &products, bool dryRun)
{
m_project = project;
m_products = products;
@@ -370,7 +370,7 @@ InternalBuildJob::InternalBuildJob(const Logger &logger, QObject *parent)
}
void InternalBuildJob::build(const TopLevelProjectPtr &project,
- const QList<ResolvedProductPtr> &products, const BuildOptions &buildOptions)
+ const QVector<ResolvedProductPtr> &products, const BuildOptions &buildOptions)
{
setup(project, products, buildOptions.dryRun());
setTimed(buildOptions.logElapsedTime());
@@ -414,7 +414,8 @@ InternalCleanJob::InternalCleanJob(const Logger &logger, QObject *parent)
}
void InternalCleanJob::init(const TopLevelProjectPtr &project,
- const QList<ResolvedProductPtr> &products, const CleanOptions &options)
+ const QVector<ResolvedProductPtr> &products,
+ const CleanOptions &options)
{
setup(project, products, options.dryRun());
setTimed(options.logElapsedTime());
diff --git a/src/lib/corelib/api/internaljobs.h b/src/lib/corelib/api/internaljobs.h
index 58127eb05..866f2f1b1 100644
--- a/src/lib/corelib/api/internaljobs.h
+++ b/src/lib/corelib/api/internaljobs.h
@@ -151,7 +151,7 @@ class BuildGraphTouchingJob : public InternalJob
{
Q_OBJECT
public:
- const QList<ResolvedProductPtr> &products() const { return m_products; }
+ const QVector<ResolvedProductPtr> &products() const { return m_products; }
const TopLevelProjectPtr &project() const { return m_project; }
signals:
@@ -162,13 +162,13 @@ protected:
BuildGraphTouchingJob(const Logger &logger, QObject *parent = nullptr);
~BuildGraphTouchingJob() override;
- void setup(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
+ void setup(const TopLevelProjectPtr &project, const QVector<ResolvedProductPtr> &products,
bool dryRun);
void storeBuildGraph();
private:
TopLevelProjectPtr m_project;
- QList<ResolvedProductPtr> m_products;
+ QVector<ResolvedProductPtr> m_products;
bool m_dryRun;
};
@@ -179,7 +179,7 @@ class InternalBuildJob : public BuildGraphTouchingJob
public:
InternalBuildJob(const Logger &logger, QObject *parent = nullptr);
- void build(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
+ void build(const TopLevelProjectPtr &project, const QVector<ResolvedProductPtr> &products,
const BuildOptions &buildOptions);
private:
@@ -196,8 +196,8 @@ class InternalCleanJob : public BuildGraphTouchingJob
public:
InternalCleanJob(const Logger &logger, QObject *parent = nullptr);
- void init(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
- const CleanOptions &options);
+ void init(const TopLevelProjectPtr &project, const QVector<ResolvedProductPtr> &products,
+ const CleanOptions &options);
private:
void start() override;
diff --git a/src/lib/corelib/api/jobs.cpp b/src/lib/corelib/api/jobs.cpp
index 32b7accc7..3ffb33814 100644
--- a/src/lib/corelib/api/jobs.cpp
+++ b/src/lib/corelib/api/jobs.cpp
@@ -309,7 +309,7 @@ BuildJob::BuildJob(const Logger &logger, QObject *parent)
this, &BuildJob::reportProcessResult);
}
-void BuildJob::build(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
+void BuildJob::build(const TopLevelProjectPtr &project, const QVector<ResolvedProductPtr> &products,
const BuildOptions &options)
{
if (!lockProject(project))
@@ -340,7 +340,7 @@ CleanJob::CleanJob(const Logger &logger, QObject *parent)
{
}
-void CleanJob::clean(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
+void CleanJob::clean(const TopLevelProjectPtr &project, const QVector<ResolvedProductPtr> &products,
const qbs::CleanOptions &options)
{
if (!lockProject(project))
@@ -361,7 +361,8 @@ InstallJob::InstallJob(const Logger &logger, QObject *parent)
}
void InstallJob::install(const TopLevelProjectPtr &project,
- const QList<ResolvedProductPtr> &products, const InstallOptions &options)
+ const QVector<ResolvedProductPtr> &products,
+ const InstallOptions &options)
{
if (!lockProject(project))
return;
diff --git a/src/lib/corelib/api/jobs.h b/src/lib/corelib/api/jobs.h
index 36c6b7a80..64929489e 100644
--- a/src/lib/corelib/api/jobs.h
+++ b/src/lib/corelib/api/jobs.h
@@ -136,7 +136,7 @@ private:
BuildJob(const Internal::Logger &logger, QObject *parent);
void build(const Internal::TopLevelProjectPtr &project,
- const QList<qbs::Internal::ResolvedProductPtr> &products,
+ const QVector<Internal::ResolvedProductPtr> &products,
const BuildOptions &options);
void handleLauncherError(const ErrorInfo &error);
@@ -153,7 +153,7 @@ private:
CleanJob(const Internal::Logger &logger, QObject *parent);
void clean(const Internal::TopLevelProjectPtr &project,
- const QList<Internal::ResolvedProductPtr> &products, const CleanOptions &options);
+ const QVector<Internal::ResolvedProductPtr> &products, const CleanOptions &options);
};
class QBS_EXPORT InstallJob : public AbstractJob
@@ -164,7 +164,8 @@ private:
InstallJob(const Internal::Logger &logger, QObject *parent);
void install(const Internal::TopLevelProjectPtr &project,
- const QList<Internal::ResolvedProductPtr> &products, const InstallOptions &options);
+ const QVector<Internal::ResolvedProductPtr> &products,
+ const InstallOptions &options);
};
} // namespace qbs
diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp
index 2186426c9..2b07f1a8d 100644
--- a/src/lib/corelib/api/project.cpp
+++ b/src/lib/corelib/api/project.cpp
@@ -131,7 +131,7 @@ ProjectData ProjectPrivate::projectData()
return m_projectData;
}
-static void addDependencies(QList<ResolvedProductPtr> &products)
+static void addDependencies(QVector<ResolvedProductPtr> &products)
{
for (int i = 0; i < products.size(); ++i) {
const ResolvedProductPtr &product = products.at(i);
@@ -142,11 +142,11 @@ static void addDependencies(QList<ResolvedProductPtr> &products)
}
}
-BuildJob *ProjectPrivate::buildProducts(const QList<ResolvedProductPtr> &products,
+BuildJob *ProjectPrivate::buildProducts(const QVector<ResolvedProductPtr> &products,
const BuildOptions &options, bool needsDepencencyResolving,
QObject *jobOwner)
{
- QList<ResolvedProductPtr> productsToBuild = products;
+ QVector<ResolvedProductPtr> productsToBuild = products;
if (needsDepencencyResolving)
addDependencies(productsToBuild);
@@ -156,7 +156,7 @@ BuildJob *ProjectPrivate::buildProducts(const QList<ResolvedProductPtr> &product
return job;
}
-CleanJob *ProjectPrivate::cleanProducts(const QList<ResolvedProductPtr> &products,
+CleanJob *ProjectPrivate::cleanProducts(const QVector<ResolvedProductPtr> &products,
const CleanOptions &options, QObject *jobOwner)
{
const auto job = new CleanJob(logger, jobOwner);
@@ -165,10 +165,10 @@ CleanJob *ProjectPrivate::cleanProducts(const QList<ResolvedProductPtr> &product
return job;
}
-InstallJob *ProjectPrivate::installProducts(const QList<ResolvedProductPtr> &products,
+InstallJob *ProjectPrivate::installProducts(const QVector<ResolvedProductPtr> &products,
const InstallOptions &options, bool needsDepencencyResolving, QObject *jobOwner)
{
- QList<ResolvedProductPtr> productsToInstall = products;
+ QVector<ResolvedProductPtr> productsToInstall = products;
if (needsDepencencyResolving)
addDependencies(productsToInstall);
const auto job = new InstallJob(logger, jobOwner);
@@ -177,9 +177,9 @@ InstallJob *ProjectPrivate::installProducts(const QList<ResolvedProductPtr> &pro
return job;
}
-QList<ResolvedProductPtr> ProjectPrivate::internalProducts(const QList<ProductData> &products) const
+QVector<ResolvedProductPtr> ProjectPrivate::internalProducts(const QList<ProductData> &products) const
{
- QList<ResolvedProductPtr> internalProducts;
+ QVector<ResolvedProductPtr> internalProducts;
for (const ProductData &product : products) {
if (product.isEnabled())
internalProducts.push_back(internalProduct(product));
@@ -187,10 +187,10 @@ QList<ResolvedProductPtr> ProjectPrivate::internalProducts(const QList<ProductDa
return internalProducts;
}
-static QList<ResolvedProductPtr> enabledInternalProducts(const ResolvedProjectConstPtr &project,
+static QVector<ResolvedProductPtr> enabledInternalProducts(const ResolvedProjectConstPtr &project,
bool includingNonDefault)
{
- QList<ResolvedProductPtr> products;
+ QVector<ResolvedProductPtr> products;
for (const ResolvedProductPtr &p : project->products) {
if (p->enabled && (includingNonDefault || p->builtByDefault()))
products.push_back(p);
@@ -200,7 +200,8 @@ static QList<ResolvedProductPtr> enabledInternalProducts(const ResolvedProjectCo
return products;
}
-QList<ResolvedProductPtr> ProjectPrivate::allEnabledInternalProducts(bool includingNonDefault) const
+QVector<ResolvedProductPtr> ProjectPrivate::allEnabledInternalProducts(
+ bool includingNonDefault) const
{
return enabledInternalProducts(internalProject, includingNonDefault);
}
@@ -355,7 +356,7 @@ void ProjectPrivate::addGroup(const ProductData &product, const QString &groupNa
QList<ProductData> products = findProductsByName(product.name());
if (products.empty())
throw ErrorInfo(Tr::tr("Product '%1' does not exist.").arg(product.name()));
- const QList<ResolvedProductPtr> resolvedProducts = internalProducts(products);
+ const auto resolvedProducts = internalProducts(products);
QBS_CHECK(products.size() == resolvedProducts.size());
for (const GroupPtr &resolvedGroup : resolvedProducts.front()->groups) {
diff --git a/src/lib/corelib/api/project_p.h b/src/lib/corelib/api/project_p.h
index 283bb5be4..2afc9cd79 100644
--- a/src/lib/corelib/api/project_p.h
+++ b/src/lib/corelib/api/project_p.h
@@ -68,16 +68,16 @@ public:
}
ProjectData projectData();
- BuildJob *buildProducts(const QList<ResolvedProductPtr> &products, const BuildOptions &options,
+ BuildJob *buildProducts(const QVector<ResolvedProductPtr> &products, const BuildOptions &options,
bool needsDepencencyResolving,
QObject *jobOwner);
- CleanJob *cleanProducts(const QList<ResolvedProductPtr> &products, const CleanOptions &options,
+ CleanJob *cleanProducts(const QVector<ResolvedProductPtr> &products, const CleanOptions &options,
QObject *jobOwner);
- InstallJob *installProducts(const QList<ResolvedProductPtr> &products,
+ InstallJob *installProducts(const QVector<ResolvedProductPtr> &products,
const InstallOptions &options, bool needsDepencencyResolving,
QObject *jobOwner);
- QList<ResolvedProductPtr> internalProducts(const QList<ProductData> &products) const;
- QList<ResolvedProductPtr> allEnabledInternalProducts(bool includingNonDefault) const;
+ QVector<ResolvedProductPtr> internalProducts(const QList<ProductData> &products) const;
+ QVector<ResolvedProductPtr> allEnabledInternalProducts(bool includingNonDefault) const;
ResolvedProductPtr internalProduct(const ProductData &product) const;
ProductData findProductData(const ProductData &product) const;
QList<ProductData> findProductsByName(const QString &name) const;
@@ -92,7 +92,7 @@ public:
void setupInstallData(ArtifactData &artifact, const ResolvedProductConstPtr &product);
struct GroupUpdateContext {
- QList<ResolvedProductPtr> resolvedProducts;
+ QVector<ResolvedProductPtr> resolvedProducts;
QList<GroupPtr> resolvedGroups;
QList<ProductData> products;
QList<GroupData> groups;
diff --git a/src/lib/corelib/buildgraph/artifactcleaner.cpp b/src/lib/corelib/buildgraph/artifactcleaner.cpp
index 000dfda02..03b327232 100644
--- a/src/lib/corelib/buildgraph/artifactcleaner.cpp
+++ b/src/lib/corelib/buildgraph/artifactcleaner.cpp
@@ -162,7 +162,7 @@ ArtifactCleaner::ArtifactCleaner(Logger logger, ProgressObserver *observer)
}
void ArtifactCleaner::cleanup(const TopLevelProjectPtr &project,
- const QList<ResolvedProductPtr> &products, const CleanOptions &options)
+ const QVector<ResolvedProductPtr> &products, const CleanOptions &options)
{
m_hasError = false;
diff --git a/src/lib/corelib/buildgraph/artifactcleaner.h b/src/lib/corelib/buildgraph/artifactcleaner.h
index 5112a75d6..8d0bef275 100644
--- a/src/lib/corelib/buildgraph/artifactcleaner.h
+++ b/src/lib/corelib/buildgraph/artifactcleaner.h
@@ -54,7 +54,7 @@ class ArtifactCleaner
{
public:
ArtifactCleaner(Logger logger, ProgressObserver *observer);
- void cleanup(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
+ void cleanup(const TopLevelProjectPtr &project, const QVector<ResolvedProductPtr> &products,
const CleanOptions &options);
private:
diff --git a/src/lib/corelib/buildgraph/nodetreedumper.cpp b/src/lib/corelib/buildgraph/nodetreedumper.cpp
index 89975baf2..df55bcca3 100644
--- a/src/lib/corelib/buildgraph/nodetreedumper.cpp
+++ b/src/lib/corelib/buildgraph/nodetreedumper.cpp
@@ -57,7 +57,7 @@ NodeTreeDumper::NodeTreeDumper(QIODevice &outDevice) : m_outDevice(outDevice)
{
}
-void NodeTreeDumper::start(const QList<ResolvedProductPtr> &products)
+void NodeTreeDumper::start(const QVector<ResolvedProductPtr> &products)
{
m_indentation = 0;
for (const ResolvedProductPtr &p : products) {
diff --git a/src/lib/corelib/buildgraph/nodetreedumper.h b/src/lib/corelib/buildgraph/nodetreedumper.h
index 4175ce727..b171a0cdf 100644
--- a/src/lib/corelib/buildgraph/nodetreedumper.h
+++ b/src/lib/corelib/buildgraph/nodetreedumper.h
@@ -57,7 +57,7 @@ class NodeTreeDumper : public BuildGraphVisitor
public:
NodeTreeDumper(QIODevice &outDevice);
- void start(const QList<ResolvedProductPtr> &products);
+ void start(const QVector<ResolvedProductPtr> &products);
private:
bool visit(Artifact *artifact) override;
diff --git a/src/lib/corelib/buildgraph/timestampsupdater.cpp b/src/lib/corelib/buildgraph/timestampsupdater.cpp
index d31f57445..3f5279dd2 100644
--- a/src/lib/corelib/buildgraph/timestampsupdater.cpp
+++ b/src/lib/corelib/buildgraph/timestampsupdater.cpp
@@ -83,7 +83,7 @@ private:
};
void TimestampsUpdater::updateTimestamps(const TopLevelProjectPtr &project,
- const QList<ResolvedProductPtr> &products, const Logger &logger)
+ const QVector<ResolvedProductPtr> &products, const Logger &logger)
{
TimestampsUpdateVisitor v;
for (const ResolvedProductPtr &product : products)
diff --git a/src/lib/corelib/buildgraph/timestampsupdater.h b/src/lib/corelib/buildgraph/timestampsupdater.h
index cfe20df12..8184ca708 100644
--- a/src/lib/corelib/buildgraph/timestampsupdater.h
+++ b/src/lib/corelib/buildgraph/timestampsupdater.h
@@ -51,7 +51,7 @@ class TimestampsUpdater
{
public:
void updateTimestamps(const TopLevelProjectPtr &project,
- const QList<ResolvedProductPtr> &products, const Logger &logger);
+ const QVector<ResolvedProductPtr> &products, const Logger &logger);
};
} // namespace Internal