Fix a couple places where we were creating vectors with default elements rather than reserving space.

This commit is contained in:
A.J. Beamon 2020-10-09 10:51:06 -07:00
parent 761fca3b4a
commit 3b66a1f2d4
2 changed files with 6 additions and 3 deletions

View File

@ -175,8 +175,11 @@ public:
}
vector<StorageServerInterface> getLastKnownServerInterfaces() const override {
vector<StorageServerInterface> v(servers.size());
for (const auto& server : servers) v.push_back(server->lastKnownInterface);
vector<StorageServerInterface> v;
v.reserve(servers.size());
for (const auto& server : servers) {
v.push_back(server->lastKnownInterface);
}
return v;
}
int size() const override {

View File

@ -94,7 +94,7 @@ class ParallelTCInfo : public ReferenceCounted<ParallelTCInfo>, public IDataDist
template <class T>
vector<T> collect(std::function<vector<T>(IDataDistributionTeam const&)> func) const {
vector<T> result(teams.size());
vector<T> result;
for (const auto& team : teams) {
vector<T> newItems = func(*team);