From 918f6a0cfd7260db3ff9476b34b350891f7c4df4 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 22 Oct 2019 02:12:58 +0300 Subject: [PATCH] Use td::contains and td::remove instead of std::find if possible. GitOrigin-RevId: faa0863eb49ee8ce4c2138dfec022620f71d2f6a --- td/telegram/AnimationsManager.cpp | 5 +- td/telegram/BackgroundManager.cpp | 11 +--- td/telegram/ContactsManager.cpp | 56 +++++++------------ td/telegram/InlineQueriesManager.cpp | 6 +- td/telegram/MessageContent.cpp | 2 +- td/telegram/MessagesManager.cpp | 20 ++----- td/telegram/NotificationManager.cpp | 5 +- td/telegram/PollManager.cpp | 3 +- td/telegram/StickersManager.cpp | 37 +++++------- td/telegram/files/FileGcWorker.cpp | 7 +-- td/telegram/files/FileManager.cpp | 7 +-- .../db/binlog/detail/BinlogEventsBuffer.cpp | 4 ++ tddb/td/db/binlog/detail/BinlogEventsBuffer.h | 2 + .../db/binlog/detail/BinlogEventsProcessor.h | 2 + tdutils/td/utils/Hints.cpp | 2 +- test/set_with_position.cpp | 4 +- 16 files changed, 66 insertions(+), 107 deletions(-) diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index a9949e7d6..10ec5c9ca 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -754,8 +754,7 @@ void AnimationsManager::remove_saved_animation(const tl_object_ptr BackgroundManager::get_backgrounds_objec return get_background_object(background_id, for_dark_theme); }); auto background_id = set_background_id_[for_dark_theme]; - if (background_id.is_valid() && std::find(installed_background_ids_.begin(), installed_background_ids_.end(), - background_id) == installed_background_ids_.end()) { + if (background_id.is_valid() && !td::contains(installed_background_ids_, background_id)) { backgrounds.push_back(get_background_object(background_id, for_dark_theme)); } std::stable_sort(backgrounds.begin(), backgrounds.end(), diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index ce7b0b3c9..18fb7b9f5 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5822,18 +5822,15 @@ void ContactsManager::update_dialogs_for_discussion(DialogId dialog_id, bool is_ return; } - auto it = std::find(dialogs_for_discussion_.begin(), dialogs_for_discussion_.end(), dialog_id); - bool is_found = it != dialogs_for_discussion_.end(); - if (is_suitable == is_found) { - return; - } - if (is_suitable) { - LOG(DEBUG) << "Add " << dialog_id << " to list of suitable discussion chats"; - dialogs_for_discussion_.insert(dialogs_for_discussion_.begin(), dialog_id); + if (!td::contains(dialogs_for_discussion_, dialog_id)) { + LOG(DEBUG) << "Add " << dialog_id << " to list of suitable discussion chats"; + dialogs_for_discussion_.insert(dialogs_for_discussion_.begin(), dialog_id); + } } else { - LOG(DEBUG) << "Remove " << dialog_id << " from list of suitable discussion chats"; - dialogs_for_discussion_.erase(it); + if (td::remove(dialogs_for_discussion_, dialog_id)) { + LOG(DEBUG) << "Remove " << dialog_id << " from list of suitable discussion chats"; + } } } @@ -7743,8 +7740,7 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from if (c->username.empty()) { td::remove(created_public_channels_, channel_id); } else { - if (std::find(created_public_channels_.begin(), created_public_channels_.end(), channel_id) == - created_public_channels_.end()) { + if (!td::contains(created_public_channels_, channel_id)) { created_public_channels_.push_back(channel_id); } } @@ -9241,9 +9237,7 @@ void ContactsManager::speculative_add_channel_participants(ChannelId channel_id, } } - if (channel_full != nullptr && is_user_bot(user_id) && - std::find(channel_full->bot_user_ids.begin(), channel_full->bot_user_ids.end(), user_id) == - channel_full->bot_user_ids.end()) { + if (channel_full != nullptr && is_user_bot(user_id) && !td::contains(channel_full->bot_user_ids, user_id)) { channel_full->bot_user_ids.push_back(user_id); channel_full->need_save_to_database = true; } @@ -9280,13 +9274,9 @@ void ContactsManager::speculative_delete_channel_participant(ChannelId channel_i if (is_user_bot(deleted_user_id)) { auto channel_full = get_channel_full_force(channel_id); - if (channel_full != nullptr) { - auto user_it = std::find(channel_full->bot_user_ids.begin(), channel_full->bot_user_ids.end(), deleted_user_id); - if (user_it != channel_full->bot_user_ids.end()) { - channel_full->bot_user_ids.erase(user_it); - channel_full->need_save_to_database = true; - update_channel_full(channel_full, channel_id); - } + if (channel_full != nullptr && td::remove(channel_full->bot_user_ids, deleted_user_id)) { + channel_full->need_save_to_database = true; + update_channel_full(channel_full, channel_id); } } @@ -9332,16 +9322,15 @@ void ContactsManager::speculative_add_channel_user(ChannelId channel_id, UserId auto administrators_it = dialog_administrators_.find(dialog_id); if (administrators_it != dialog_administrators_.end()) { auto user_ids = administrators_it->second; - auto it = std::find(user_ids.begin(), user_ids.end(), user_id); - bool is_found = it != user_ids.end(); - - if (new_status.is_administrator() != is_found) { - if (is_found) { - user_ids.erase(it); - } else { + if (new_status.is_administrator()) { + if (!td::contains(user_ids, user_id)) { user_ids.push_back(user_id); + on_update_dialog_administrators(dialog_id, std::move(user_ids), true); + } + } else { + if (td::remove(user_ids, user_id)) { + on_update_dialog_administrators(dialog_id, std::move(user_ids), true); } - on_update_dialog_administrators(dialog_id, std::move(user_ids), true); } } } @@ -9384,15 +9373,12 @@ void ContactsManager::speculative_add_channel_user(ChannelId channel_id, UserId if (new_status.is_member() != old_status.is_member() && is_user_bot(user_id)) { if (new_status.is_member()) { - if (std::find(channel_full->bot_user_ids.begin(), channel_full->bot_user_ids.end(), user_id) == - channel_full->bot_user_ids.end()) { + if (!td::contains(channel_full->bot_user_ids, user_id)) { channel_full->bot_user_ids.push_back(user_id); channel_full->need_save_to_database = true; } } else { - auto user_it = std::find(channel_full->bot_user_ids.begin(), channel_full->bot_user_ids.end(), user_id); - if (user_it != channel_full->bot_user_ids.end()) { - channel_full->bot_user_ids.erase(user_it); + if (td::remove(channel_full->bot_user_ids, user_id)) { channel_full->need_save_to_database = true; } } diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 5a852c62b..e49518208 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -1713,12 +1713,10 @@ bool InlineQueriesManager::update_bot_usage(UserId bot_user_id) { } void InlineQueriesManager::remove_recent_inline_bot(UserId bot_user_id, Promise &&promise) { - auto it = std::find(recently_used_bot_user_ids_.begin(), recently_used_bot_user_ids_.end(), bot_user_id); - if (it != recently_used_bot_user_ids_.end()) { - recently_used_bot_user_ids_.erase(it); + if (td::remove(recently_used_bot_user_ids_, bot_user_id)) { save_recently_used_bots(); } - return promise.set_value(Unit()); + promise.set_value(Unit()); } } // namespace td diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 8616bb9ac..bd24275bb 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -4849,7 +4849,7 @@ bool need_delay_message_content_notification(const MessageContent *content, User return true; case MessageContentType::ChatAddUsers: { auto &added_user_ids = static_cast(content)->user_ids; - return std::find(added_user_ids.begin(), added_user_ids.end(), my_user_id) == added_user_ids.end(); + return !td::contains(added_user_ids, my_user_id); } case MessageContentType::ChatDeleteUser: return static_cast(content)->user_id != my_user_id; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 372854df6..063a170ba 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -11394,7 +11394,7 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vectorpeer_); - if (std::find(added_dialog_ids.begin(), added_dialog_ids.end(), dialog_id) != added_dialog_ids.end()) { + if (td::contains(added_dialog_ids, dialog_id)) { LOG(ERROR) << "Receive " << dialog_id << " twice in result of getChats with total_count = " << total_count; continue; } @@ -12729,7 +12729,7 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int32 offset_chat_id CHECK(dialog_id.is_valid()); td_->contacts_manager_->on_get_chat(std::move(chat), "on_get_common_dialogs"); - if (std::find(result.begin(), result.end(), dialog_id) == result.end()) { + if (!td::contains(result, dialog_id)) { force_create_dialog(dialog_id, "get common dialogs"); result.push_back(dialog_id); } @@ -13169,7 +13169,7 @@ Result MessagesManager::get_message_link_info( if (begins_with(cur_t_me_url, "http://") || begins_with(cur_t_me_url, "https://")) { Slice t_me_url = cur_t_me_url; t_me_url = t_me_url.substr(url[4] == 's' ? 8 : 7); - if (std::find(t_me_urls.begin(), t_me_urls.end(), t_me_url) == t_me_urls.end()) { + if (!td::contains(t_me_urls, t_me_url)) { t_me_urls.push_back(t_me_url); } } @@ -22200,8 +22200,7 @@ void MessagesManager::on_dialog_bots_updated(DialogId dialog_id, vector return; } const Message *m = get_message_force(d, d->reply_markup_message_id, "on_dialog_bots_updated"); - if (m == nullptr || (m->sender_user_id.is_valid() && - std::find(bot_user_ids.begin(), bot_user_ids.end(), m->sender_user_id) == bot_user_ids.end())) { + if (m == nullptr || (m->sender_user_id.is_valid() && !td::contains(bot_user_ids, m->sender_user_id))) { LOG(INFO) << "Remove reply markup in " << dialog_id << ", because bot " << (m == nullptr ? UserId() : m->sender_user_id) << " isn't a member of the chat"; set_dialog_reply_markup(d, MessageId()); @@ -24373,8 +24372,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq if (need_delete_message_files(d, m)) { FullMessageId full_message_id{dialog_id, message_id}; for (auto file_id : old_file_ids) { - if (std::find(new_file_ids.begin(), new_file_ids.end(), file_id) == new_file_ids.end() && - need_delete_file(full_message_id, file_id)) { + if (!td::contains(new_file_ids, file_id) && need_delete_file(full_message_id, file_id)) { send_closure(G()->file_manager(), &FileManager::delete_file, file_id, Promise<>(), "edit message in add_message_to_dialog"); } @@ -28103,13 +28101,7 @@ bool MessagesManager::add_recently_found_dialog_internal(DialogId dialog_id) { bool MessagesManager::remove_recently_found_dialog_internal(DialogId dialog_id) { CHECK(have_dialog(dialog_id)); - - auto it = std::find(recently_found_dialog_ids_.begin(), recently_found_dialog_ids_.end(), dialog_id); - if (it == recently_found_dialog_ids_.end()) { - return false; - } - recently_found_dialog_ids_.erase(it); - return true; + return td::remove(recently_found_dialog_ids_, dialog_id); } void MessagesManager::suffix_load_loop(Dialog *d) { diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index a8d143420..8f77800da 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -392,8 +392,7 @@ NotificationManager::NotificationGroups::iterator NotificationManager::get_group return group_it; } - if (std::find(call_notification_group_ids_.begin(), call_notification_group_ids_.end(), group_id) != - call_notification_group_ids_.end()) { + if (td::contains(call_notification_group_ids_, group_id)) { return groups_.end(); } @@ -1263,7 +1262,7 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour auto has_common_notifications = [](const vector> ¬ifications, const vector ¬ification_ids) { for (auto ¬ification : notifications) { - if (std::find(notification_ids.begin(), notification_ids.end(), notification->id_) != notification_ids.end()) { + if (td::contains(notification_ids, notification->id_)) { return true; } } diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index c93547705..5109608de 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -429,8 +429,7 @@ td_api::object_ptr PollManager::get_poll_object(PollId poll_id, co } else { auto &chosen_options = it->second.options_; for (auto &poll_option : poll->options) { - auto is_being_chosen = - std::find(chosen_options.begin(), chosen_options.end(), poll_option.data) != chosen_options.end(); + auto is_being_chosen = td::contains(chosen_options, poll_option.data); if (poll_option.is_chosen) { voter_count_diff = -1; } diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index a2a753491..a1a743925 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1856,7 +1856,7 @@ StickerSetId StickersManager::on_get_sticker_set_covered(tl_object_ptrsticker_ids; auto sticker_id = on_get_sticker_document(std::move(covered_set->cover_)).second; - if (sticker_id.is_valid() && std::find(sticker_ids.begin(), sticker_ids.end(), sticker_id) == sticker_ids.end()) { + if (sticker_id.is_valid() && !td::contains(sticker_ids, sticker_id)) { sticker_ids.push_back(sticker_id); sticker_set->is_changed = true; } @@ -1880,8 +1880,7 @@ StickerSetId StickersManager::on_get_sticker_set_covered(tl_object_ptrcovers_) { auto sticker_id = on_get_sticker_document(std::move(cover)).second; - if (sticker_id.is_valid() && - std::find(sticker_ids.begin(), sticker_ids.end(), sticker_id) == sticker_ids.end()) { + if (sticker_id.is_valid() && !td::contains(sticker_ids, sticker_id)) { sticker_ids.push_back(sticker_id); sticker_set->is_changed = true; } @@ -1967,7 +1966,7 @@ void StickersManager::on_get_messages_sticker_set(StickerSetId sticker_set_id, } auto &sticker_ids = s->emoji_stickers_map_[remove_emoji_modifiers(pack->emoticon_)]; for (auto sticker_id : stickers) { - if (std::find(sticker_ids.begin(), sticker_ids.end(), sticker_id) == sticker_ids.end()) { + if (!td::contains(sticker_ids, sticker_id)) { sticker_ids.push_back(sticker_id); } } @@ -2165,7 +2164,7 @@ vector StickersManager::get_stickers(string emoji, int32 limit, bool for prepend_sticker_ids.reserve(favorite_sticker_ids_.size() + recent_sticker_ids_[0].size()); append(prepend_sticker_ids, recent_sticker_ids_[0]); for (auto sticker_id : favorite_sticker_ids_) { - if (std::find(prepend_sticker_ids.begin(), prepend_sticker_ids.end(), sticker_id) == prepend_sticker_ids.end()) { + if (!td::contains(prepend_sticker_ids, sticker_id)) { prepend_sticker_ids.push_back(sticker_id); } } @@ -2184,8 +2183,7 @@ vector StickersManager::get_stickers(string emoji, int32 limit, bool for for (const auto &sticker_id : prepend_sticker_ids) { const Sticker *s = get_sticker(sticker_id); LOG(INFO) << "Have prepend sticker " << sticker_id << " from " << s->set_id; - if (s->set_id.is_valid() && - std::find(sets_to_load.begin(), sets_to_load.end(), s->set_id) == sets_to_load.end()) { + if (s->set_id.is_valid() && !td::contains(sets_to_load, s->set_id)) { const StickerSet *sticker_set = get_sticker_set(s->set_id); if (sticker_set == nullptr || !sticker_set->is_loaded) { sets_to_load.push_back(s->set_id); @@ -2235,8 +2233,7 @@ vector StickersManager::get_stickers(string emoji, int32 limit, bool for continue; } - if (std::find(examined_sticker_sets.begin(), examined_sticker_sets.end(), sticker_set) == - examined_sticker_sets.end()) { + if (!td::contains(examined_sticker_sets, sticker_set)) { examined_sticker_sets.push_back(sticker_set); } } @@ -2279,7 +2276,7 @@ vector StickersManager::get_stickers(string emoji, int32 limit, bool for if (sticker_set != nullptr && sticker_set->was_loaded) { auto map_it = sticker_set->emoji_stickers_map_.find(emoji); if (map_it != sticker_set->emoji_stickers_map_.end()) { - if (std::find(map_it->second.begin(), map_it->second.end(), sticker_id) != map_it->second.end()) { + if (td::contains(map_it->second, sticker_id)) { LOG(INFO) << "Found prepend sticker " << sticker_id << " has matching emoji"; is_good = true; } @@ -2652,7 +2649,7 @@ void StickersManager::on_update_sticker_set(StickerSet *sticker_set, bool is_ins } if (is_archived) { - if (std::find(sticker_set_ids.begin(), sticker_set_ids.end(), sticker_set->id) == sticker_set_ids.end()) { + if (!td::contains(sticker_set_ids, sticker_set->id)) { total_count++; sticker_set_ids.insert(sticker_set_ids.begin(), sticker_set->id); } @@ -3108,7 +3105,7 @@ void StickersManager::on_get_archived_sticker_sets( CHECK(sticker_set != nullptr); update_sticker_set(sticker_set); - if (std::find(sticker_set_ids.begin(), sticker_set_ids.end(), sticker_set_id) == sticker_set_ids.end()) { + if (!td::contains(sticker_set_ids, sticker_set_id)) { sticker_set_ids.push_back(sticker_set_id); } } @@ -4267,8 +4264,7 @@ void StickersManager::remove_recent_sticker(bool is_attached, const tl_object_pt vector &sticker_ids = recent_sticker_ids_[is_attached]; FileId file_id = r_file_id.ok(); - auto it = std::find(sticker_ids.begin(), sticker_ids.end(), file_id); - if (it == sticker_ids.end()) { + if (!td::remove(sticker_ids, file_id)) { return promise.set_value(Unit()); } @@ -4279,8 +4275,6 @@ void StickersManager::remove_recent_sticker(bool is_attached, const tl_object_pt send_save_recent_sticker_query(is_attached, file_id, true, std::move(promise)); - sticker_ids.erase(it); - need_update_recent_stickers_[is_attached] = true; send_update_recent_stickers(); } @@ -4675,8 +4669,7 @@ void StickersManager::remove_favorite_sticker(const tl_object_ptr emojis = search_language_emojis(language_code, text, true); bool is_changed = false; for (auto &emoji : keyword->emoticons_) { - if (std::find(emojis.begin(), emojis.end(), emoji) == emojis.end()) { + if (!td::contains(emojis, emoji)) { emojis.push_back(emoji); is_changed = true; } @@ -5095,9 +5086,7 @@ void StickersManager::on_get_emoji_keywords_difference( vector emojis = search_language_emojis(language_code, text, true); bool is_changed = false; for (auto &emoji : keyword->emoticons_) { - auto it = std::find(emojis.begin(), emojis.end(), emoji); - if (it != emojis.end()) { - emojis.erase(it); + if (td::remove(emojis, emoji)) { is_changed = true; } } diff --git a/td/telegram/files/FileGcWorker.cpp b/td/telegram/files/FileGcWorker.cpp index c7f8fa421..362995a6a 100644 --- a/td/telegram/files/FileGcWorker.cpp +++ b/td/telegram/files/FileGcWorker.cpp @@ -103,15 +103,12 @@ void FileGcWorker::run_gc(const FileGcParameters ¶meters, std::vectorfile_ids_.begin(), file_node->file_ids_.end(), file_id); - CHECK(it != file_node->file_ids_.end()); - file_node->file_ids_.erase(it); + bool is_removed = td::remove(file_node->file_ids_, file_id); + CHECK(is_removed); *info = FileIdInfo(); empty_file_ids_.push_back(file_id.get()); } @@ -1038,7 +1037,7 @@ Result FileManager::register_generate(FileType file_type, FileLocationSo // add #mtime# into conversion if (!original_path.empty() && conversion[0] != '#' && PathView(original_path).is_absolute()) { auto file_paths = log_interface->get_file_paths(); - if (std::find(file_paths.begin(), file_paths.end(), original_path) == file_paths.end()) { + if (!td::contains(file_paths, original_path)) { auto r_stat = stat(original_path); uint64 mtime = r_stat.is_ok() ? r_stat.ok().mtime_nsec_ : 0; conversion = PSTRING() << "#mtime#" << lpad0(to_string(mtime), 20) << '#' << conversion; diff --git a/tddb/td/db/binlog/detail/BinlogEventsBuffer.cpp b/tddb/td/db/binlog/detail/BinlogEventsBuffer.cpp index 606f8ffcc..2036d0bde 100644 --- a/tddb/td/db/binlog/detail/BinlogEventsBuffer.cpp +++ b/tddb/td/db/binlog/detail/BinlogEventsBuffer.cpp @@ -10,6 +10,7 @@ namespace td { namespace detail { + void BinlogEventsBuffer::add_event(BinlogEvent &&event) { total_events_++; if ((event.flags_ & BinlogEvent::Flags::Partial) == 0) { @@ -26,14 +27,17 @@ void BinlogEventsBuffer::add_event(BinlogEvent &&event) { size_ += event.size_; events_.push_back(std::move(event)); } + bool BinlogEventsBuffer::need_flush() const { return total_events_ > 5000 || ids_.size() > 100; } + void BinlogEventsBuffer::clear() { ids_.clear(); events_.clear(); total_events_ = 0; size_ = 0; } + } // namespace detail } // namespace td diff --git a/tddb/td/db/binlog/detail/BinlogEventsBuffer.h b/tddb/td/db/binlog/detail/BinlogEventsBuffer.h index 35fa19061..0f8689361 100644 --- a/tddb/td/db/binlog/detail/BinlogEventsBuffer.h +++ b/tddb/td/db/binlog/detail/BinlogEventsBuffer.h @@ -12,6 +12,7 @@ namespace td { namespace detail { + class BinlogEventsBuffer { public: void add_event(BinlogEvent &&event); @@ -45,5 +46,6 @@ class BinlogEventsBuffer { void do_event(BinlogEvent &&event); void clear(); }; + } // namespace detail } // namespace td diff --git a/tddb/td/db/binlog/detail/BinlogEventsProcessor.h b/tddb/td/db/binlog/detail/BinlogEventsProcessor.h index 0d3417d39..d69a969d9 100644 --- a/tddb/td/db/binlog/detail/BinlogEventsProcessor.h +++ b/tddb/td/db/binlog/detail/BinlogEventsProcessor.h @@ -14,6 +14,7 @@ namespace td { namespace detail { + class BinlogEventsProcessor { public: Status add_event(BinlogEvent &&event) TD_WARN_UNUSED_RESULT { @@ -54,5 +55,6 @@ class BinlogEventsProcessor { Status do_event(BinlogEvent &&event); void compactify(); }; + } // namespace detail } // namespace td diff --git a/tdutils/td/utils/Hints.cpp b/tdutils/td/utils/Hints.cpp index a9180e3a3..531e51611 100644 --- a/tdutils/td/utils/Hints.cpp +++ b/tdutils/td/utils/Hints.cpp @@ -68,7 +68,7 @@ vector Hints::get_words(Slice name, bool is_search) { void Hints::add_word(const string &word, KeyT key, std::map> &word_to_keys) { vector &keys = word_to_keys[word]; - CHECK(std::find(keys.begin(), keys.end(), key) == keys.end()); + CHECK(!td::contains(keys, key)); keys.push_back(key); } diff --git a/test/set_with_position.cpp b/test/set_with_position.cpp index f5da39615..d9f2f9e08 100644 --- a/test/set_with_position.cpp +++ b/test/set_with_position.cpp @@ -7,6 +7,7 @@ #include "td/telegram/SetWithPosition.h" #include "td/utils/common.h" +#include "td/utils/misc.h" #include "td/utils/Random.h" #include "td/utils/tests.h" @@ -21,8 +22,7 @@ template class OldSetWithPosition { public: void add(T value) { - auto it = std::find(values_.begin(), values_.end(), value); - if (it != values_.end()) { + if (td::contains(values_, value)) { return; } values_.push_back(value);