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/08/23 00:54:43 UTC
mesos git commit: Avoid validating star role when validating resource
role.
Repository: mesos
Updated Branches:
refs/heads/master c3228f3c3 -> 4000fd31b
Avoid validating star role when validating resource role.
The `roles::validate` is time consuming and it was called by
`Resources::validate`, the `Resources::validate` was called
frequently when add/subtract `Resource` object.
This patch is avoiding the `roles::validate` for star role as
there is no need to validate such role.
Review: https://reviews.apache.org/r/51034/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4000fd31
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4000fd31
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4000fd31
Branch: refs/heads/master
Commit: 4000fd31b88f2640c31ce3224ba28e6f8da895e0
Parents: c3228f3
Author: Guangya Liu <gy...@gmail.com>
Authored: Mon Aug 22 17:50:34 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Mon Aug 22 17:54:11 2016 -0700
----------------------------------------------------------------------
src/common/roles.cpp | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4000fd31/src/common/roles.cpp
----------------------------------------------------------------------
diff --git a/src/common/roles.cpp b/src/common/roles.cpp
index 017f8a6..31774a9 100644
--- a/src/common/roles.cpp
+++ b/src/common/roles.cpp
@@ -57,11 +57,19 @@ static const string* INVALID_CHARACTERS =
Option<Error> validate(const string& role)
{
- static const string* dot = new string(".");
- static const string* dotdot = new string("..");
+ // We check * explicitly first as a performance improvement.
+ static const string* star = new string("*");
+ if (role == *star) {
+ return None();
+ }
+
if (role.empty()) {
return Error("Empty role name is invalid");
- } else if (role == *dot) {
+ }
+
+ static const string* dot = new string(".");
+ static const string* dotdot = new string("..");
+ if (role == *dot) {
return Error("Role name '.' is invalid");
} else if (role == *dotdot) {
return Error("Role name '..' is invalid");