mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
common/str_list: remove unnecessary function get_str_set
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>
This commit is contained in:
parent
73bdad0552
commit
2d36320842
@ -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;
|
||||
}
|
||||
|
@ -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**
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user