Fix full_split behavior on empty string.
GitOrigin-RevId: 74fcaeee970ab26f1bee221babf9b6029237c6cc
This commit is contained in:
parent
6fc90bb699
commit
bc54e5e335
@ -1614,12 +1614,6 @@ bool InlineQueriesManager::load_recently_used_bots(Promise<Unit> &promise) {
|
|||||||
auto bot_ids = full_split(saved_bot_ids, ',');
|
auto bot_ids = full_split(saved_bot_ids, ',');
|
||||||
string saved_bots = G()->td_db()->get_binlog_pmc()->get("recently_used_inline_bot_usernames");
|
string saved_bots = G()->td_db()->get_binlog_pmc()->get("recently_used_inline_bot_usernames");
|
||||||
auto bot_usernames = full_split(saved_bots, ',');
|
auto bot_usernames = full_split(saved_bots, ',');
|
||||||
if (bot_ids.size() == 1 && bot_ids[0].empty()) {
|
|
||||||
bot_ids.clear();
|
|
||||||
}
|
|
||||||
if (bot_usernames.size() == 1 && bot_usernames[0].empty()) {
|
|
||||||
bot_usernames.clear();
|
|
||||||
}
|
|
||||||
if (bot_ids.empty() && bot_usernames.empty()) {
|
if (bot_ids.empty() && bot_usernames.empty()) {
|
||||||
recently_used_bots_loaded_ = 2;
|
recently_used_bots_loaded_ = 2;
|
||||||
if (!recently_used_bot_user_ids_.empty()) {
|
if (!recently_used_bot_user_ids_.empty()) {
|
||||||
|
@ -34,6 +34,9 @@ std::pair<T, T> split(T s, char delimiter = ' ') {
|
|||||||
template <class T>
|
template <class T>
|
||||||
vector<T> full_split(T s, char delimiter = ' ') {
|
vector<T> full_split(T s, char delimiter = ' ') {
|
||||||
vector<T> result;
|
vector<T> result;
|
||||||
|
if (s.empty()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
auto delimiter_pos = s.find(delimiter);
|
auto delimiter_pos = s.find(delimiter);
|
||||||
if (delimiter_pos == string::npos) {
|
if (delimiter_pos == string::npos) {
|
||||||
|
@ -544,7 +544,7 @@ static void test_full_split(Slice str, vector<Slice> expected) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Misc, full_split) {
|
TEST(Misc, full_split) {
|
||||||
test_full_split("", {""});
|
test_full_split("", {});
|
||||||
test_full_split(" ", {"", ""});
|
test_full_split(" ", {"", ""});
|
||||||
test_full_split(" ", {"", "", ""});
|
test_full_split(" ", {"", "", ""});
|
||||||
test_full_split("abcdef", {"abcdef"});
|
test_full_split("abcdef", {"abcdef"});
|
||||||
|
Reference in New Issue
Block a user