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 2016/02/05 01:17:49 UTC

mesos git commit: Used `std::any_of` instead of `std::count_if` when validating IDs.

Repository: mesos
Updated Branches:
  refs/heads/master d467eeeb8 -> 022662074


Used `std::any_of` instead of `std::count_if` when validating IDs.

This makes the intent slightly clearer. In principle, it should save a
few cycles as well, but nothing significant. Also, clarify the name of
a helper function.

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


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

Branch: refs/heads/master
Commit: 0226620747e1769434a1a83da547bfc3470a9549
Parents: d467eee
Author: Neil Conway <ne...@gmail.com>
Authored: Thu Feb 4 14:47:13 2016 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Thu Feb 4 16:06:05 2016 -0800

----------------------------------------------------------------------
 src/master/validation.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/02266207/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index f2bc1ba..66898e9 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -44,7 +44,7 @@ namespace validation {
 
 // A helper function which returns true if the given character is not
 // suitable for an ID.
-static bool invalid(char c)
+static bool invalidCharacter(char c)
 {
   return iscntrl(c) || c == '/' || c == '\\';
 }
@@ -198,7 +198,7 @@ Option<Error> validateDiskInfo(const RepeatedPtrField<Resource>& resources)
 
       // Ensure persistence ID does not have invalid characters.
       string id = resource.disk().persistence().id();
-      if (std::count_if(id.begin(), id.end(), invalid) > 0) {
+      if (std::any_of(id.begin(), id.end(), invalidCharacter)) {
         return Error("Persistence ID '" + id + "' contains invalid characters");
       }
     } else if (resource.disk().has_volume()) {
@@ -287,7 +287,7 @@ Option<Error> validateTaskID(const TaskInfo& task)
 {
   const string& id = task.task_id().value();
 
-  if (std::count_if(id.begin(), id.end(), invalid) > 0) {
+  if (std::any_of(id.begin(), id.end(), invalidCharacter)) {
     return Error("TaskID '" + id + "' contains invalid characters");
   }