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/01/10 00:28:24 UTC
[3/3] mesos git commit: Cleaned up `std::string` usage in mesos.
Cleaned up `std::string` usage in mesos.
- Avoided redundant initialization to empty string.
- Used `char` overloads instead for single-character string literals.
Spotted with `clang-tidy`.
Review: https://reviews.apache.org/r/55220/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c0aee8cc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c0aee8cc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c0aee8cc
Branch: refs/heads/master
Commit: c0aee8cc10b1d1f4b2db5ff12b771372fdd5b1f3
Parents: 9fcb719
Author: Neil Conway <ne...@gmail.com>
Authored: Mon Jan 9 14:24:22 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Jan 9 16:28:08 2017 -0800
----------------------------------------------------------------------
src/common/resources.cpp | 4 ++--
src/docker/docker.cpp | 2 +-
src/slave/containerizer/fetcher.cpp | 4 ++--
src/state/zookeeper.cpp | 4 ++--
src/tests/environment.cpp | 2 +-
src/v1/resources.cpp | 4 ++--
src/zookeeper/zookeeper.cpp | 2 +-
7 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 7dbeefc..be9bca2 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -661,12 +661,12 @@ Try<vector<Resource>> Resources::fromSimpleString(
string name;
string role;
- size_t openParen = pair[0].find("(");
+ size_t openParen = pair[0].find('(');
if (openParen == string::npos) {
name = strings::trim(pair[0]);
role = defaultRole;
} else {
- size_t closeParen = pair[0].find(")");
+ size_t closeParen = pair[0].find(')');
if (closeParen == string::npos || closeParen < openParen) {
return Error(
"Bad value for resources, mismatched parentheses in " + token);
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index 472cb1b..b63b060 100755
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -532,7 +532,7 @@ Future<Option<int>> Docker::run(
}
}
- string environmentVariables = "";
+ string environmentVariables;
if (env.isSome()) {
foreachpair (const string& key, const string& value, env.get()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/slave/containerizer/fetcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/fetcher.cpp b/src/slave/containerizer/fetcher.cpp
index 94cfa0e..ba2e118 100644
--- a/src/slave/containerizer/fetcher.cpp
+++ b/src/slave/containerizer/fetcher.cpp
@@ -133,11 +133,11 @@ Try<string> Fetcher::basename(const string& uri)
// ftp://, ftps://, hdfs://, hftp://, s3://, s3n://.
string path = uri.substr(index + 3);
- if (!strings::contains(path, "/") || path.size() <= path.find("/") + 1) {
+ if (!strings::contains(path, "/") || path.size() <= path.find('/') + 1) {
return Error("Malformed URI (missing path): " + uri);
}
- return path.substr(path.find_last_of("/") + 1);
+ return path.substr(path.find_last_of('/') + 1);
}
return Path(uri).basename();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/state/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/state/zookeeper.cpp b/src/state/zookeeper.cpp
index 9941f6b..1abd816 100644
--- a/src/state/zookeeper.cpp
+++ b/src/state/zookeeper.cpp
@@ -502,11 +502,11 @@ Result<bool> ZooKeeperStorageProcess::doSet(const Entry& entry,
if (code == ZNONODE) {
// Create directory path znodes as necessary.
CHECK(znode.size() == 0 || znode.at(znode.size() - 1) != '/');
- size_t index = znode.find("/", 0);
+ size_t index = znode.find('/', 0);
while (index < string::npos) {
// Get out the prefix to create.
- index = znode.find("/", index + 1);
+ index = znode.find('/', index + 1);
string prefix = znode.substr(0, index);
// Create the znode (even if it already exists).
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index a683d8c..6fe26e5 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -801,7 +801,7 @@ void Environment::SetUp()
string variable = env[i];
if (variable.find("MESOS_") == 0) {
string key;
- size_t eq = variable.find_first_of("=");
+ size_t eq = variable.find_first_of('=');
if (eq == string::npos) {
continue; // Not expecting a missing '=', but ignore anyway.
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 859f738..da4701c 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -661,12 +661,12 @@ Try<vector<Resource>> Resources::fromSimpleString(
string name;
string role;
- size_t openParen = pair[0].find("(");
+ size_t openParen = pair[0].find('(');
if (openParen == string::npos) {
name = strings::trim(pair[0]);
role = defaultRole;
} else {
- size_t closeParen = pair[0].find(")");
+ size_t closeParen = pair[0].find(')');
if (closeParen == string::npos || closeParen < openParen) {
return Error(
"Bad value for resources, mismatched parentheses in " + token);
http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/zookeeper/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/zookeeper/zookeeper.cpp b/src/zookeeper/zookeeper.cpp
index e105377..5ede4e5 100644
--- a/src/zookeeper/zookeeper.cpp
+++ b/src/zookeeper/zookeeper.cpp
@@ -260,7 +260,7 @@ public:
// because, it doesn't return the expected path when a path ends
// with "/". For example, to create path "/a/b/", we want to
// recursively create "/a/b", instead of just creating "/a".
- const string& parent = path.substr(0, path.find_last_of("/"));
+ const string& parent = path.substr(0, path.find_last_of('/'));
if (!parent.empty()) {
return create(parent, "", acl, 0, result, true)
.then(defer(self(),