]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/str_list: remove unnecessary function get_str_set 35613/head
authorChangcheng Liu <changcheng.liu@aliyun.com>
Mon, 27 Jul 2020 07:35:16 +0000 (15:35 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Tue, 28 Jul 2020 02:48:54 +0000 (10:48 +0800)
1. get_str_set isn't used.
2. In future, it should use for_each_substr for better performance where
   get_str_set is needed.

Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/common/str_list.cc
src/include/str_list.h
src/test/test_str_list.cc

index 33a1157d1349e963bf7abd0302123f4fee549fe7..016155e98b7332262a30183f816802d1f042dc29 100644 (file)
@@ -61,24 +61,3 @@ vector<string> get_str_vec(const string& str, const char *delims)
   get_str_vec(str, delims, result);
   return result;
 }
-
-void get_str_set(const string& str, const char *delims, set<string>& str_set)
-{
-  str_set.clear();
-  for_each_substr(str, delims, [&str_set] (auto token) {
-      str_set.emplace(token.begin(), token.end());
-    });
-}
-
-void get_str_set(const string& str, set<string>& str_set)
-{
-  const char *delims = ";,= \t";
-  get_str_set(str, delims, str_set);
-}
-
-set<string> get_str_set(const string& str, const char *delims)
-{
-  set<string> result;
-  get_str_set(str, delims, result);
-  return result;
-}
index 68822c65a2e8f571f67662cc407afe61ea745d93..1ca61099a247b7f2f810b9068a0ef651915d08bd 100644 (file)
@@ -70,37 +70,6 @@ extern void get_str_vec(const std::string& str,
 
 std::vector<std::string> get_str_vec(const std::string& str,
                                      const char *delims = ";,= \t");
-/**
- * Split **str** into a set of strings, using the ";,= \t" delimiters and output the result in **str_set**.
- * 
- * @param [in] str String to split and save as Set
- * @param [out] str_set Set modified containing str after it has been split
-**/
-extern void get_str_set(const std::string& str,
-                       std::set<std::string>& str_set);
-
-/**
- * Split **str** into a set of strings, using the **delims** delimiters and output the result in **str_set**.
- * 
- * @param [in] str String to split and save as Set
- * @param [in] delims characters used to split **str**
- * @param [out] str_set Set modified containing str after it has been split
-**/
-template<class Compare = std::less<std::string> >
-void get_str_set(const std::string& str,
-                 const char *delims,
-                 std::set<std::string, Compare>& str_set)
-{
-  str_set.clear();
-  for_each_substr(str, delims, [&str_set] (auto token) {
-                  str_set.emplace(token.begin(), token.end());
-                  });
-}
-
-std::set<std::string> get_str_set(const std::string& str,
-                                  const char *delims = ";,= \t");
-
-
 
 /**
  * Return a String containing the vector **v** joined with **sep**
index cb2536dd7378cc8752e578c9801f88731cb7b396..363395011e983f61b0e22365f3b157dd680220d5 100644 (file)
@@ -7,8 +7,7 @@
 
 // SplitTest is parameterized for list/vector/set
 using Types = ::testing::Types<std::list<std::string>,
-                               std::vector<std::string>,
-                               std::set<std::string>>;
+                               std::vector<std::string>>;
 
 template <typename T>
 struct SplitTest : ::testing::Test {
@@ -20,10 +19,6 @@ struct SplitTest : ::testing::Test {
             const std::vector<std::string>& expected) {
     EXPECT_EQ(expected, get_str_vec(input, delim));
   }
-  void test(const char* input, const char *delim,
-            const std::set<std::string>& expected) {
-    EXPECT_EQ(expected, get_str_set(input, delim));
-  }
 };
 
 TYPED_TEST_SUITE(SplitTest, Types);