summaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-03-22 23:44:17 +0100
committerHenning Baldersheim <balder@oath.com>2018-04-03 18:33:28 +0200
commit8c80fadcafb2d600ae72d01f5e2034a3ed8df670 (patch)
tree94f5e8cfceaf417f1a0b3cf0da25b7089eb5c5af /vdslib
parent2efcbf7038eb951c140e9aacd32105772c5d8ddb (diff)
Use move constructors.
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/vespa/vdslib/distribution/distribution.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/vdslib/src/vespa/vdslib/distribution/distribution.cpp b/vdslib/src/vespa/vdslib/distribution/distribution.cpp
index ff84687210d..9b31d10d8e8 100644
--- a/vdslib/src/vespa/vdslib/distribution/distribution.cpp
+++ b/vdslib/src/vespa/vdslib/distribution/distribution.cpp
@@ -549,8 +549,7 @@ Distribution::getIdealNodes(const NodeType& nodeType,
uint32_t seed;
if (nodeType == NodeType::STORAGE) {
seed = getStorageSeed(bucket, clusterState);
- getIdealGroups(bucket, clusterState, *_nodeGraph, redundancy,
- _groupDistribution);
+ getIdealGroups(bucket, clusterState, *_nodeGraph, redundancy, _groupDistribution);
} else {
seed = getDistributorSeed(bucket, clusterState);
const Group* group(getIdealDistributorGroup(bucket, clusterState, *_nodeGraph));
@@ -566,8 +565,7 @@ Distribution::getIdealNodes(const NodeType& nodeType,
uint32_t randomIndex = 0;
for (uint32_t i=0, n=_groupDistribution.size(); i<n; ++i) {
uint16_t groupRedundancy(_groupDistribution[i]._redundancy);
- const std::vector<uint16_t>& nodes(
- _groupDistribution[i]._group->getNodes());
+ const std::vector<uint16_t>& nodes(_groupDistribution[i]._group->getNodes());
// Create temporary place to hold results. Use double linked list
// for cheap access to back(). Stuff in redundancy fake entries to
// avoid needing to check size during iteration.
@@ -576,15 +574,11 @@ Distribution::getIdealNodes(const NodeType& nodeType,
// Verify that the node is legal target before starting to grab
// random number. Helps worst case of having to start new random
// seed if the node that is out of order is illegal anyways.
- const NodeState& nodeState(
- clusterState.getNodeState(Node(nodeType, nodes[j])));
+ const NodeState& nodeState(clusterState.getNodeState(Node(nodeType, nodes[j])));
if (!nodeState.getState().oneOf(upStates)) continue;
if (nodeState.isAnyDiskDown()) {
- uint16_t idealDiskIndex(getIdealDisk(
- nodeState, nodes[j], bucket, IDEAL_DISK_EVEN_IF_DOWN));
- if (nodeState.getDiskState(idealDiskIndex).getState()
- != State::UP)
- {
+ uint16_t idealDiskIndex(getIdealDisk(nodeState, nodes[j], bucket, IDEAL_DISK_EVEN_IF_DOWN));
+ if (nodeState.getDiskState(idealDiskIndex).getState() != State::UP) {
continue;
}
}
@@ -611,8 +605,7 @@ Distribution::getIdealNodes(const NodeType& nodeType,
it != tmpResults.end(); ++it)
{
if (score > it->_score) {
- tmpResults.insert(it, ScoredNode(
- nodes[j], nodeState.getReliability(), score));
+ tmpResults.insert(it, ScoredNode(nodes[j], nodeState.getReliability(), score));
break;
}
}
@@ -620,10 +613,9 @@ Distribution::getIdealNodes(const NodeType& nodeType,
}
}
trimResult(tmpResults, groupRedundancy);
- for (std::list<ScoredNode>::iterator it = tmpResults.begin();
- it != tmpResults.end(); ++it)
- {
- resultNodes.push_back(it->_index);
+ resultNodes.reserve(resultNodes.size() + tmpResults.size());
+ for (const auto & scored : tmpResults) {
+ resultNodes.push_back(scored._index);
}
}
}