You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/07/29 20:40:14 UTC

mesos git commit: Used `add` instead of `+=` for `Resources::filter`.

Repository: mesos
Updated Branches:
  refs/heads/master 93d695959 -> 044bd9833


Used `add` instead of `+=` for `Resources::filter`.

The current logic of `Resources::filter` is using `+=` to add
the filtered resource object and the `+=` resource object will
invoke `validate` which is not necessary as all of the resource
objects are valid.

The fix is using `add` instead of `+=` for `Resources::filter`,
this can make sure there is no validation and can improve
performance of `Resources::filter` for resources object.

Review: https://reviews.apache.org/r/50557/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/044bd983
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/044bd983
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/044bd983

Branch: refs/heads/master
Commit: 044bd9833573dd6a497876ead174e237339bad3d
Parents: 93d6959
Author: Guangya Liu <gy...@gmail.com>
Authored: Fri Jul 29 13:39:57 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Jul 29 13:39:57 2016 -0700

----------------------------------------------------------------------
 src/common/resources.cpp | 2 +-
 src/v1/resources.cpp     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/044bd983/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 1fe7909..69166de 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -849,7 +849,7 @@ Resources Resources::filter(
   Resources result;
   foreach (const Resource& resource, resources) {
     if (predicate(resource)) {
-      result += resource;
+      result.add(resource);
     }
   }
   return result;

http://git-wip-us.apache.org/repos/asf/mesos/blob/044bd983/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index c62bc35..90897e3 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -852,7 +852,7 @@ Resources Resources::filter(
   Resources result;
   foreach (const Resource& resource, resources) {
     if (predicate(resource)) {
-      result += resource;
+      result.add(resource);
     }
   }
   return result;