You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/10/27 00:07:13 UTC

svn commit: r1402692 - /incubator/mesos/trunk/third_party/libprocess/include/stout/strings.hpp

Author: benh
Date: Fri Oct 26 22:07:13 2012
New Revision: 1402692

URL: http://svn.apache.org/viewvc?rev=1402692&view=rev
Log:
Refactored strings::join to be more Pythonic.

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

Modified:
    incubator/mesos/trunk/third_party/libprocess/include/stout/strings.hpp

Modified: incubator/mesos/trunk/third_party/libprocess/include/stout/strings.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/stout/strings.hpp?rev=1402692&r1=1402691&r2=1402692&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/stout/strings.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/stout/strings.hpp Fri Oct 26 22:07:13 2012
@@ -140,20 +140,30 @@ inline std::map<std::string, std::vector
 }
 
 
-// Returns a string which is the concatenation of the strings in
-// items, the separator is inserted between elements.
-inline std::string join(const std::vector<std::string>& items,
-                        const std::string& separator = "") {
-  if (items.empty()) {
-    return "";
-  }
+inline std::string join(const std::string& separator,
+                        const std::string& s1,
+                        const std::string& s2)
+{
+  return s1 + separator + s2;
+}
 
-  std::string result = items[0];
-  for (size_t i = 1; i < items.size(); ++i) {
-    result.append(separator);
-    result.append(items[i]);
-  }
-  return result;
+
+inline std::string join(const std::string& separator,
+                        const std::string& s1,
+                        const std::string& s2,
+                        const std::string& s3)
+{
+  return s1 + separator + s2 + separator + s3;
+}
+
+
+inline std::string join(const std::string& separator,
+                        const std::string& s1,
+                        const std::string& s2,
+                        const std::string& s4,
+                        const std::string& s3)
+{
+  return s1 + separator + s2 + separator + s3 + separator + s4;
 }