From 3b66a1f2d41595ebdd99841e552f493f75fafb01 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Fri, 9 Oct 2020 10:51:06 -0700 Subject: [PATCH] Fix a couple places where we were creating vectors with default elements rather than reserving space. --- fdbserver/DataDistribution.actor.cpp | 7 +++++-- fdbserver/DataDistributionQueue.actor.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fdbserver/DataDistribution.actor.cpp b/fdbserver/DataDistribution.actor.cpp index 51fecd52ed..537b7944bb 100644 --- a/fdbserver/DataDistribution.actor.cpp +++ b/fdbserver/DataDistribution.actor.cpp @@ -175,8 +175,11 @@ public: } vector getLastKnownServerInterfaces() const override { - vector v(servers.size()); - for (const auto& server : servers) v.push_back(server->lastKnownInterface); + vector v; + v.reserve(servers.size()); + for (const auto& server : servers) { + v.push_back(server->lastKnownInterface); + } return v; } int size() const override { diff --git a/fdbserver/DataDistributionQueue.actor.cpp b/fdbserver/DataDistributionQueue.actor.cpp index 3d84b78554..eed153d942 100644 --- a/fdbserver/DataDistributionQueue.actor.cpp +++ b/fdbserver/DataDistributionQueue.actor.cpp @@ -94,7 +94,7 @@ class ParallelTCInfo : public ReferenceCounted, public IDataDist template vector collect(std::function(IDataDistributionTeam const&)> func) const { - vector result(teams.size()); + vector result; for (const auto& team : teams) { vector newItems = func(*team);