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/07/04 18:34:05 UTC
mesos git commit: Enhanced the performance of `startsWith` and
`endsWith`.
Repository: mesos
Updated Branches:
refs/heads/master aecafbe0c -> 5e42b96c9
Enhanced the performance of `startsWith` and `endsWith`.
Review: https://reviews.apache.org/r/49246/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5e42b96c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5e42b96c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5e42b96c
Branch: refs/heads/master
Commit: 5e42b96c99d253556ce97e1d98703f4ba6c482d7
Parents: aecafbe
Author: Klaus Ma <kl...@gmail.com>
Authored: Mon Jul 4 17:23:25 2016 +0200
Committer: Michael Park <mp...@apache.org>
Committed: Mon Jul 4 20:33:19 2016 +0200
----------------------------------------------------------------------
3rdparty/stout/include/stout/strings.hpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5e42b96c/3rdparty/stout/include/stout/strings.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/strings.hpp b/3rdparty/stout/include/stout/strings.hpp
index 1de77d0..7f7f1cf 100644
--- a/3rdparty/stout/include/stout/strings.hpp
+++ b/3rdparty/stout/include/stout/strings.hpp
@@ -367,7 +367,8 @@ inline bool checkBracketsMatching(
inline bool startsWith(const std::string& s, const std::string& prefix)
{
- return s.find(prefix) == 0;
+ return s.size() >= prefix.size() &&
+ std::equal(prefix.begin(), prefix.end(), s.begin());
}
@@ -379,7 +380,8 @@ inline bool startsWith(const std::string& s, char c)
inline bool endsWith(const std::string& s, const std::string& suffix)
{
- return s.rfind(suffix) == s.length() - suffix.length();
+ return s.size() >= suffix.size() &&
+ std::equal(suffix.rbegin(), suffix.rend(), s.rbegin());
}