You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/01/26 21:19:10 UTC

[2/4] mesos git commit: Improved performance of 'roles::validate'.

Improved performance of 'roles::validate'.

This validation is used inside resource math which in turn is used
heavily in the code base.
The temporary string allocations caused a significant performance
degradation in this critical path.

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


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

Branch: refs/heads/master
Commit: 1ca71df9b528deb8ac98e567548cb8a81079ab25
Parents: 8821a75
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Mon Jan 25 15:22:27 2016 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Jan 26 12:00:27 2016 -0800

----------------------------------------------------------------------
 src/common/roles.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1ca71df9/src/common/roles.cpp
----------------------------------------------------------------------
diff --git a/src/common/roles.cpp b/src/common/roles.cpp
index 5be8070..3f00b9e 100644
--- a/src/common/roles.cpp
+++ b/src/common/roles.cpp
@@ -56,13 +56,15 @@ static const string INVALID_CHARACTERS = "\x09\x0a\x0b\x0c\x0d\x20\x2f\x7f";
 
 Option<Error> validate(const string& role)
 {
+  static const string dot = ".";
+  static const string dotdot = "..";
   if (role.empty()) {
     return Error("Empty role name is invalid.");
-  } else if (role == ".") {
+  } else if (role == dot) {
     return Error("Role name '.' is invalid.");
-  } else if (role == "..") {
+  } else if (role == dotdot) {
     return Error("Role name '..' is invalid.");
-  } else if (strings::startsWith(role, "-")) {
+  } else if (role[0] == '-') {
     return Error("Role name '" + role + "' is invalid "
                  "because it starts with a dash.");
   }