You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/02/08 00:38:21 UTC
[5/7] mesos git commit: Cleaned up code style slightly in the DRF
sorter.
Cleaned up code style slightly in the DRF sorter.
Review: https://reviews.apache.org/r/56249/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2d41532e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2d41532e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2d41532e
Branch: refs/heads/master
Commit: 2d41532ee6d381f1928a18e0041da2460595c621
Parents: bb97ff4
Author: Neil Conway <ne...@gmail.com>
Authored: Mon Feb 6 13:05:18 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Tue Feb 7 16:23:26 2017 -0800
----------------------------------------------------------------------
src/master/allocator/sorter/drf/sorter.cpp | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2d41532e/src/master/allocator/sorter/drf/sorter.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp
index 5681a5d..db1fc0e 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -178,9 +178,8 @@ void DRFSorter::allocated(
allocations[name].totals[resource.name()] += resource.scalar();
}
- // If the total resources have changed, we're going to
- // recalculate all the shares, so don't bother just
- // updating this client.
+ // If the total resources have changed, we're going to recalculate
+ // all the shares, so don't bother just updating this client.
if (!dirty) {
update(name);
}
@@ -388,10 +387,7 @@ vector<string> DRFSorter::sort()
if (dirty) {
set<Client, DRFComparator> temp;
- set<Client, DRFComparator>::iterator it;
- for (it = clients.begin(); it != clients.end(); it++) {
- Client client(*it);
-
+ foreach (Client client, clients) {
// Update the 'share' to get proper sorting.
client.share = calculateShare(client.name);
@@ -408,9 +404,8 @@ vector<string> DRFSorter::sort()
vector<string> result;
result.reserve(clients.size());
- set<Client, DRFComparator>::iterator it;
- for (it = clients.begin(); it != clients.end(); it++) {
- result.push_back((*it).name);
+ foreach (const Client& client, clients) {
+ result.push_back(client.name);
}
return result;
@@ -482,7 +477,7 @@ set<Client, DRFComparator>::iterator DRFSorter::find(const string& name)
{
set<Client, DRFComparator>::iterator it;
for (it = clients.begin(); it != clients.end(); it++) {
- if (name == (*it).name) {
+ if (name == it->name) {
break;
}
}