Use td::unique.
This commit is contained in:
parent
45149bb3cd
commit
192fd4862f
@ -1699,8 +1699,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
|
|
||||||
// do not update suggested actions while changing content settings or dismissing an action
|
// do not update suggested actions while changing content settings or dismissing an action
|
||||||
if (!is_set_content_settings_request_sent_ && dismiss_suggested_action_request_count_ == 0) {
|
if (!is_set_content_settings_request_sent_ && dismiss_suggested_action_request_count_ == 0) {
|
||||||
std::sort(suggested_actions.begin(), suggested_actions.end());
|
td::unique(suggested_actions);
|
||||||
suggested_actions.erase(std::unique(suggested_actions.begin(), suggested_actions.end()), suggested_actions.end());
|
|
||||||
if (suggested_actions != suggested_actions_) {
|
if (suggested_actions != suggested_actions_) {
|
||||||
vector<SuggestedAction> added_actions;
|
vector<SuggestedAction> added_actions;
|
||||||
vector<SuggestedAction> removed_actions;
|
vector<SuggestedAction> removed_actions;
|
||||||
|
@ -1253,10 +1253,7 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour
|
|||||||
auto update_ptr = static_cast<td_api::updateNotificationGroup *>(update.get());
|
auto update_ptr = static_cast<td_api::updateNotificationGroup *>(update.get());
|
||||||
append(update_ptr->removed_notification_ids_, std::move(moved_deleted_notification_ids));
|
append(update_ptr->removed_notification_ids_, std::move(moved_deleted_notification_ids));
|
||||||
auto old_size = update_ptr->removed_notification_ids_.size();
|
auto old_size = update_ptr->removed_notification_ids_.size();
|
||||||
std::sort(update_ptr->removed_notification_ids_.begin(), update_ptr->removed_notification_ids_.end());
|
td::unique(update_ptr->removed_notification_ids_);
|
||||||
update_ptr->removed_notification_ids_.erase(
|
|
||||||
std::unique(update_ptr->removed_notification_ids_.begin(), update_ptr->removed_notification_ids_.end()),
|
|
||||||
update_ptr->removed_notification_ids_.end());
|
|
||||||
CHECK(old_size == update_ptr->removed_notification_ids_.size());
|
CHECK(old_size == update_ptr->removed_notification_ids_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,8 +675,7 @@ string PollManager::get_poll_search_text(PollId poll_id) const {
|
|||||||
|
|
||||||
void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector<int32> &&option_ids,
|
void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector<int32> &&option_ids,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
std::sort(option_ids.begin(), option_ids.end());
|
td::unique(option_ids);
|
||||||
option_ids.erase(std::unique(option_ids.begin(), option_ids.end()), option_ids.end());
|
|
||||||
|
|
||||||
if (is_local_poll_id(poll_id)) {
|
if (is_local_poll_id(poll_id)) {
|
||||||
return promise.set_error(Status::Error(400, "Poll can't be answered"));
|
return promise.set_error(Status::Error(400, "Poll can't be answered"));
|
||||||
|
@ -410,8 +410,7 @@ vector<int32> PrivacyManager::UserPrivacySettingRules::get_restricted_user_ids()
|
|||||||
for (auto &rule : rules_) {
|
for (auto &rule : rules_) {
|
||||||
combine(result, rule.get_restricted_user_ids());
|
combine(result, rule.get_restricted_user_ids());
|
||||||
}
|
}
|
||||||
std::sort(result.begin(), result.end());
|
td::unique(result);
|
||||||
result.erase(std::unique(result.begin(), result.end()), result.end());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ class FastSetWithPosition {
|
|||||||
res.push_back(*not_checked_.begin());
|
res.push_back(*not_checked_.begin());
|
||||||
res.push_back(*not_checked_.rbegin());
|
res.push_back(*not_checked_.rbegin());
|
||||||
}
|
}
|
||||||
std::sort(res.begin(), res.end());
|
td::unique(res);
|
||||||
res.erase(std::unique(res.begin(), res.end()), res.end());
|
|
||||||
if (res.size() > 2) {
|
if (res.size() > 2) {
|
||||||
res.erase(res.begin() + 1, res.end() - 1);
|
res.erase(res.begin() + 1, res.end() - 1);
|
||||||
}
|
}
|
||||||
|
@ -6154,8 +6154,7 @@ void StickersManager::on_get_language_codes(const string &key, Result<vector<str
|
|||||||
LOG(ERROR) << "Language codes list is empty";
|
LOG(ERROR) << "Language codes list is empty";
|
||||||
language_codes.emplace_back("en");
|
language_codes.emplace_back("en");
|
||||||
}
|
}
|
||||||
std::sort(language_codes.begin(), language_codes.end());
|
td::unique(language_codes);
|
||||||
language_codes.erase(std::unique(language_codes.begin(), language_codes.end()), language_codes.end());
|
|
||||||
|
|
||||||
auto it = emoji_language_codes_.find(key);
|
auto it = emoji_language_codes_.find(key);
|
||||||
CHECK(it != emoji_language_codes_.end());
|
CHECK(it != emoji_language_codes_.end());
|
||||||
@ -6207,8 +6206,7 @@ vector<string> StickersManager::get_emoji_language_codes(const vector<string> &i
|
|||||||
LOG(INFO) << "List of language codes is empty";
|
LOG(INFO) << "List of language codes is empty";
|
||||||
language_codes.push_back("en");
|
language_codes.push_back("en");
|
||||||
}
|
}
|
||||||
std::sort(language_codes.begin(), language_codes.end());
|
td::unique(language_codes);
|
||||||
language_codes.erase(std::unique(language_codes.begin(), language_codes.end()), language_codes.end());
|
|
||||||
|
|
||||||
LOG(DEBUG) << "Have language codes " << language_codes;
|
LOG(DEBUG) << "Have language codes " << language_codes;
|
||||||
auto key = get_emoji_language_codes_database_key(language_codes);
|
auto key = get_emoji_language_codes_database_key(language_codes);
|
||||||
@ -6474,8 +6472,7 @@ vector<string> StickersManager::search_emojis(const string &text, bool exact_mat
|
|||||||
combine(result, search_language_emojis(language_code, text_lowered, exact_match));
|
combine(result, search_language_emojis(language_code, text_lowered, exact_match));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(result.begin(), result.end());
|
td::unique(result);
|
||||||
result.erase(std::unique(result.begin(), result.end()), result.end());
|
|
||||||
|
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
return result;
|
return result;
|
||||||
|
@ -1231,8 +1231,7 @@ Result<FileId> FileManager::register_file(FileData &&data, FileLocationSource fi
|
|||||||
if (file_view.has_generate_location()) {
|
if (file_view.has_generate_location()) {
|
||||||
new_generate = register_location(file_view.generate_location(), generate_location_to_file_id_);
|
new_generate = register_location(file_view.generate_location(), generate_location_to_file_id_);
|
||||||
}
|
}
|
||||||
std::sort(to_merge.begin(), to_merge.end());
|
td::unique(to_merge);
|
||||||
to_merge.erase(std::unique(to_merge.begin(), to_merge.end()), to_merge.end());
|
|
||||||
|
|
||||||
int new_cnt = new_remote + new_local + new_generate;
|
int new_cnt = new_remote + new_local + new_generate;
|
||||||
if (data.pmc_id_ == 0 && file_db_ && new_cnt > 0) {
|
if (data.pmc_id_ == 0 && file_db_ && new_cnt > 0) {
|
||||||
|
@ -153,8 +153,7 @@ vector<Hints::KeyT> Hints::search_word(const string &word) const {
|
|||||||
add_search_results(results, w, word_to_keys_);
|
add_search_results(results, w, word_to_keys_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(results.begin(), results.end());
|
td::unique(results);
|
||||||
results.erase(std::unique(results.begin(), results.end()), results.end());
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +107,7 @@ vector<string> get_word_transliterations(Slice word, bool allow_partial) {
|
|||||||
add_word_transliterations(result, word, allow_partial, get_en_to_ru_simple_rules(), get_en_to_ru_complex_rules());
|
add_word_transliterations(result, word, allow_partial, get_en_to_ru_simple_rules(), get_en_to_ru_complex_rules());
|
||||||
add_word_transliterations(result, word, allow_partial, get_ru_to_en_simple_rules(), get_ru_to_en_complex_rules());
|
add_word_transliterations(result, word, allow_partial, get_ru_to_en_simple_rules(), get_ru_to_en_complex_rules());
|
||||||
|
|
||||||
std::sort(result.begin(), result.end());
|
td::unique(result);
|
||||||
result.erase(std::unique(result.begin(), result.end()), result.end());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,8 +210,9 @@ TEST(Port, SignalsAndThread) {
|
|||||||
}
|
}
|
||||||
std::sort(ptrs.begin(), ptrs.end());
|
std::sort(ptrs.begin(), ptrs.end());
|
||||||
CHECK(ptrs == ans);
|
CHECK(ptrs == ans);
|
||||||
std::sort(addrs.begin(), addrs.end());
|
auto addrs_size = addrs.size();
|
||||||
ASSERT_TRUE(std::unique(addrs.begin(), addrs.end()) == addrs.end());
|
td::unique(addrs);
|
||||||
|
ASSERT_EQ(addrs_size, addrs.size());
|
||||||
//LOG(ERROR) << addrs;
|
//LOG(ERROR) << addrs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user