mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-17 07:37:51 +01:00
Delete redundant function rtc::tokenize_with_empty_tokens
It was identical to rtc::split. Bug: webrtc:6424 Change-Id: I1118ad34050c0eb324ade347c97174f3ad4b39a7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231234 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#34946}
This commit is contained in:
parent
4f0a9194d9
commit
634f27950e
5 changed files with 20 additions and 40 deletions
|
@ -171,12 +171,12 @@ static RTCErrorType ParseIceServerUrl(
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
cricket::ProtocolType turn_transport_type = cricket::PROTO_UDP;
|
cricket::ProtocolType turn_transport_type = cricket::PROTO_UDP;
|
||||||
RTC_DCHECK(!url.empty());
|
RTC_DCHECK(!url.empty());
|
||||||
rtc::tokenize_with_empty_tokens(url, '?', &tokens);
|
rtc::split(url, '?', &tokens);
|
||||||
std::string uri_without_transport = tokens[0];
|
std::string uri_without_transport = tokens[0];
|
||||||
// Let's look into transport= param, if it exists.
|
// Let's look into transport= param, if it exists.
|
||||||
if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present.
|
if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present.
|
||||||
std::string uri_transport_param = tokens[1];
|
std::string uri_transport_param = tokens[1];
|
||||||
rtc::tokenize_with_empty_tokens(uri_transport_param, '=', &tokens);
|
rtc::split(uri_transport_param, '=', &tokens);
|
||||||
if (tokens[0] != kTransport) {
|
if (tokens[0] != kTransport) {
|
||||||
RTC_LOG(LS_WARNING) << "Invalid transport parameter key.";
|
RTC_LOG(LS_WARNING) << "Invalid transport parameter key.";
|
||||||
return RTCErrorType::SYNTAX_ERROR;
|
return RTCErrorType::SYNTAX_ERROR;
|
||||||
|
|
|
@ -102,7 +102,7 @@ rtc::StringBuilder& operator<<(rtc::StringBuilder& builder,
|
||||||
// rid-id = 1*(alpha-numeric / "-" / "_") ; see: I-D.ietf-mmusic-rid
|
// rid-id = 1*(alpha-numeric / "-" / "_") ; see: I-D.ietf-mmusic-rid
|
||||||
RTCErrorOr<SimulcastLayerList> ParseSimulcastLayerList(const std::string& str) {
|
RTCErrorOr<SimulcastLayerList> ParseSimulcastLayerList(const std::string& str) {
|
||||||
std::vector<std::string> tokens;
|
std::vector<std::string> tokens;
|
||||||
rtc::tokenize_with_empty_tokens(str, kDelimiterSemicolonChar, &tokens);
|
rtc::split(str, kDelimiterSemicolonChar, &tokens);
|
||||||
if (tokens.empty()) {
|
if (tokens.empty()) {
|
||||||
return ParseError("Layer list cannot be empty.");
|
return ParseError("Layer list cannot be empty.");
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ RTCErrorOr<SimulcastLayerList> ParseSimulcastLayerList(const std::string& str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> rid_tokens;
|
std::vector<std::string> rid_tokens;
|
||||||
rtc::tokenize_with_empty_tokens(token, kDelimiterCommaChar, &rid_tokens);
|
rtc::split(token, kDelimiterCommaChar, &rid_tokens);
|
||||||
|
|
||||||
if (rid_tokens.empty()) {
|
if (rid_tokens.empty()) {
|
||||||
return ParseError("Simulcast alternative layer list is malformed.");
|
return ParseError("Simulcast alternative layer list is malformed.");
|
||||||
|
|
|
@ -171,21 +171,6 @@ size_t tokenize(const std::string& source,
|
||||||
return fields->size();
|
return fields->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tokenize_with_empty_tokens(const std::string& source,
|
|
||||||
char delimiter,
|
|
||||||
std::vector<std::string>* fields) {
|
|
||||||
fields->clear();
|
|
||||||
size_t last = 0;
|
|
||||||
for (size_t i = 0; i < source.length(); ++i) {
|
|
||||||
if (source[i] == delimiter) {
|
|
||||||
fields->push_back(source.substr(last, i - last));
|
|
||||||
last = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fields->push_back(source.substr(last, source.length() - last));
|
|
||||||
return fields->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool tokenize_first(const std::string& source,
|
bool tokenize_first(const std::string& source,
|
||||||
const char delimiter,
|
const char delimiter,
|
||||||
std::string* token,
|
std::string* token,
|
||||||
|
|
|
@ -72,11 +72,6 @@ size_t tokenize(const std::string& source,
|
||||||
char delimiter,
|
char delimiter,
|
||||||
std::vector<std::string>* fields);
|
std::vector<std::string>* fields);
|
||||||
|
|
||||||
// Tokenize, including the empty tokens.
|
|
||||||
size_t tokenize_with_empty_tokens(const std::string& source,
|
|
||||||
char delimiter,
|
|
||||||
std::vector<std::string>* fields);
|
|
||||||
|
|
||||||
// Extract the first token from source as separated by delimiter, with
|
// Extract the first token from source as separated by delimiter, with
|
||||||
// duplicates of delimiter ignored. Return false if the delimiter could not be
|
// duplicates of delimiter ignored. Return false if the delimiter could not be
|
||||||
// found, otherwise return true.
|
// found, otherwise return true.
|
||||||
|
|
|
@ -169,22 +169,6 @@ TEST(TokenizeTest, CompareSubstrings) {
|
||||||
ASSERT_EQ(0ul, fields.size());
|
ASSERT_EQ(0ul, fields.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TokenizeTest, TokenizeWithEmptyTokens) {
|
|
||||||
std::vector<std::string> fields;
|
|
||||||
EXPECT_EQ(3ul, tokenize_with_empty_tokens("a.b.c", '.', &fields));
|
|
||||||
EXPECT_EQ("a", fields[0]);
|
|
||||||
EXPECT_EQ("b", fields[1]);
|
|
||||||
EXPECT_EQ("c", fields[2]);
|
|
||||||
|
|
||||||
EXPECT_EQ(3ul, tokenize_with_empty_tokens("..c", '.', &fields));
|
|
||||||
EXPECT_TRUE(fields[0].empty());
|
|
||||||
EXPECT_TRUE(fields[1].empty());
|
|
||||||
EXPECT_EQ("c", fields[2]);
|
|
||||||
|
|
||||||
EXPECT_EQ(1ul, tokenize_with_empty_tokens("", '.', &fields));
|
|
||||||
EXPECT_TRUE(fields[0].empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(TokenizeFirstTest, NoLeadingSpaces) {
|
TEST(TokenizeFirstTest, NoLeadingSpaces) {
|
||||||
std::string token;
|
std::string token;
|
||||||
std::string rest;
|
std::string rest;
|
||||||
|
@ -267,6 +251,22 @@ TEST(SplitTest, CompareSubstrings) {
|
||||||
ASSERT_STREQ("", fields.at(0).c_str());
|
ASSERT_STREQ("", fields.at(0).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SplitTest, EmptyTokens) {
|
||||||
|
std::vector<std::string> fields;
|
||||||
|
EXPECT_EQ(3ul, split("a.b.c", '.', &fields));
|
||||||
|
EXPECT_EQ("a", fields[0]);
|
||||||
|
EXPECT_EQ("b", fields[1]);
|
||||||
|
EXPECT_EQ("c", fields[2]);
|
||||||
|
|
||||||
|
EXPECT_EQ(3ul, split("..c", '.', &fields));
|
||||||
|
EXPECT_TRUE(fields[0].empty());
|
||||||
|
EXPECT_TRUE(fields[1].empty());
|
||||||
|
EXPECT_EQ("c", fields[2]);
|
||||||
|
|
||||||
|
EXPECT_EQ(1ul, split("", '.', &fields));
|
||||||
|
EXPECT_TRUE(fields[0].empty());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(ToString, SanityCheck) {
|
TEST(ToString, SanityCheck) {
|
||||||
EXPECT_EQ(ToString(true), "true");
|
EXPECT_EQ(ToString(true), "true");
|
||||||
EXPECT_EQ(ToString(false), "false");
|
EXPECT_EQ(ToString(false), "false");
|
||||||
|
|
Loading…
Reference in a new issue