td: replace most of std::unordered_map usages to td::FlatHashMap

This commit is contained in:
Arseny Smirnov 2022-02-07 20:41:07 +01:00
parent 088ce02832
commit 86bceb2972
65 changed files with 377 additions and 361 deletions

View File

@ -20,7 +20,7 @@
#include "td/utils/common.h"
#include "td/utils/Status.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -142,7 +142,7 @@ class AnimationsManager final : public Actor {
Td *td_;
ActorShared<> parent_;
std::unordered_map<FileId, unique_ptr<Animation>, FileIdHash> animations_;
FlatHashMap<FileId, unique_ptr<Animation>, FileIdHash> animations_;
int32 saved_animations_limit_ = 200;
vector<FileId> saved_animation_ids_;

View File

@ -15,7 +15,7 @@
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -75,7 +75,7 @@ class AudiosManager {
FileId on_get_audio(unique_ptr<Audio> new_audio, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<Audio>, FileIdHash> audios_;
FlatHashMap<FileId, unique_ptr<Audio>, FileIdHash> audios_;
};
} // namespace td

View File

@ -22,7 +22,7 @@
#include "td/utils/Status.h"
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -160,17 +160,17 @@ class BackgroundManager final : public Actor {
void do_upload_background_file(FileId file_id, const BackgroundType &type, bool for_dark_theme,
tl_object_ptr<telegram_api::InputFile> &&input_file, Promise<Unit> &&promise);
std::unordered_map<BackgroundId, Background, BackgroundIdHash> backgrounds_;
FlatHashMap<BackgroundId, Background, BackgroundIdHash> backgrounds_;
std::unordered_map<BackgroundId, std::pair<int64, FileSourceId>, BackgroundIdHash>
FlatHashMap<BackgroundId, std::pair<int64, FileSourceId>, BackgroundIdHash>
background_id_to_file_source_id_; // id -> [access_hash, file_source_id]
std::unordered_map<string, BackgroundId> name_to_background_id_;
FlatHashMap<string, BackgroundId> name_to_background_id_;
std::unordered_map<FileId, BackgroundId, FileIdHash> file_id_to_background_id_;
FlatHashMap<FileId, BackgroundId, FileIdHash> file_id_to_background_id_;
std::unordered_set<string> loaded_from_database_backgrounds_;
std::unordered_map<string, vector<Promise<Unit>>> being_loaded_from_database_backgrounds_;
FlatHashMap<string, vector<Promise<Unit>>> being_loaded_from_database_backgrounds_;
BackgroundId set_background_id_[2];
BackgroundType set_background_type_[2];
@ -190,7 +190,7 @@ class BackgroundManager final : public Actor {
: type_(type), for_dark_theme_(for_dark_theme), promise_(std::move(promise)) {
}
};
std::unordered_map<FileId, UploadedFileInfo, FileIdHash> being_uploaded_files_;
FlatHashMap<FileId, UploadedFileInfo, FileIdHash> being_uploaded_files_;
BackgroundId max_local_background_id_;
vector<BackgroundId> local_background_ids_[2];

View File

@ -17,7 +17,7 @@
#include "td/utils/Status.h"
#include <map>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -48,7 +48,7 @@ class CallManager final : public Actor {
};
std::map<int64, CallInfo> call_info_;
int32 next_call_id_{1};
std::unordered_map<CallId, ActorOwn<CallActor>, CallIdHash> id_to_actor_;
FlatHashMap<CallId, ActorOwn<CallActor>, CallIdHash> id_to_actor_;
ActorId<CallActor> get_call_actor(CallId call_id);
CallId create_call_actor();

View File

@ -29,7 +29,7 @@
#include <memory>
#include <mutex>
#include <queue>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
namespace td {
@ -205,7 +205,7 @@ class ClientManager::Impl final {
ClientId client_id_{0};
Td::Options options_;
std::unordered_set<int32> pending_clients_;
std::unordered_map<int32, ActorOwn<Td>> tds_;
FlatHashMap<int32, ActorOwn<Td>> tds_;
};
class Client::Impl final {
@ -264,7 +264,7 @@ class MultiTd final : public Actor {
private:
Td::Options options_;
std::unordered_map<int32, ActorOwn<Td>> tds_;
FlatHashMap<int32, ActorOwn<Td>> tds_;
};
class TdReceiver {
@ -580,7 +580,7 @@ class ClientManager::Impl final {
std::shared_ptr<MultiImpl> impl;
bool is_closed = false;
};
std::unordered_map<ClientId, MultiImplInfo> impls_;
FlatHashMap<ClientId, MultiImplInfo> impls_;
TdReceiver receiver_;
};

View File

@ -119,7 +119,7 @@ static ClientManager *get_manager() {
}
static std::mutex extra_mutex;
static std::unordered_map<int64, string> extra;
static FlatHashMap<int64, string> extra;
static std::atomic<uint64> extra_id{1};
int json_create_client_id() {

View File

@ -14,7 +14,7 @@
#include <cstdint>
#include <mutex>
#include <string>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -30,7 +30,7 @@ class ClientJson final {
private:
Client client_;
std::mutex mutex_; // for extra_
std::unordered_map<std::int64_t, std::string> extra_;
FlatHashMap<std::int64_t, std::string> extra_;
std::atomic<std::uint64_t> extra_id_{1};
};

View File

@ -63,7 +63,7 @@
#include <functional>
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -1495,8 +1495,8 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
vector<tl_object_ptr<telegram_api::jsonObjectValue>> new_values;
string ignored_restriction_reasons;
vector<string> dice_emojis;
std::unordered_map<string, size_t> dice_emoji_index;
std::unordered_map<string, string> dice_emoji_success_value;
FlatHashMap<string, size_t> dice_emoji_index;
FlatHashMap<string, string> dice_emoji_success_value;
vector<string> emoji_sounds;
string animation_search_provider;
string animation_search_emojis;

View File

@ -58,7 +58,7 @@ string ConfigShared::get_option(Slice name) const {
return config_pmc_->get(name.str());
}
std::unordered_map<string, string> ConfigShared::get_options() const {
FlatHashMap<string, string> ConfigShared::get_options() const {
return config_pmc_->get_all();
}

View File

@ -12,7 +12,7 @@
#include "td/utils/Slice.h"
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -42,7 +42,7 @@ class ConfigShared {
string get_option(Slice name) const;
std::unordered_map<string, string> get_options() const;
FlatHashMap<string, string> get_options() const;
bool get_option_boolean(Slice name, bool default_value = false) const;
int64 get_option_integer(Slice name, int64 default_value = 0) const;

View File

@ -5493,7 +5493,7 @@ std::pair<vector<UserId>, vector<int32>> ContactsManager::change_imported_contac
vector<size_t> new_contacts_unique_id(contacts.size());
vector<Contact> unique_new_contacts;
unique_new_contacts.reserve(contacts.size());
std::unordered_map<Contact, size_t, ContactHash, ContactEqual> different_new_contacts;
FlatHashMap<Contact, size_t, ContactHash, ContactEqual> different_new_contacts;
std::unordered_set<string> different_new_phone_numbers;
size_t unique_size = 0;
for (size_t i = 0; i < contacts.size(); i++) {
@ -6694,7 +6694,7 @@ void ContactsManager::report_channel_spam(ChannelId channel_id, const vector<Mes
return promise.set_error(Status::Error(400, "Spam can be reported only by chat administrators"));
}
std::unordered_map<DialogId, vector<MessageId>, DialogIdHash> server_message_ids;
FlatHashMap<DialogId, vector<MessageId>, DialogIdHash> server_message_ids;
for (auto &message_id : message_ids) {
if (message_id.is_valid_scheduled()) {
return promise.set_error(Status::Error(400, "Can't report scheduled messages"));
@ -7984,7 +7984,7 @@ void ContactsManager::on_import_contacts_finished(int64 random_id, vector<UserId
CHECK(unimported_contact_invites.size() == add_size);
CHECK(imported_contacts_unique_id_.size() == result_size);
std::unordered_map<size_t, int32> unique_id_to_unimported_contact_invites;
FlatHashMap<size_t, int32> unique_id_to_unimported_contact_invites;
for (size_t i = 0; i < add_size; i++) {
auto unique_id = imported_contacts_pos_[i];
get_user_id_object(imported_contact_user_ids[i], "on_import_contacts_finished"); // to ensure updateUser

View File

@ -47,7 +47,7 @@
#include <functional>
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -627,7 +627,7 @@ class ContactsManager final : public Actor {
std::unordered_set<int64> photo_ids;
std::unordered_map<DialogId, int32, DialogIdHash> online_member_dialogs; // id -> time
FlatHashMap<DialogId, int32, DialogIdHash> online_member_dialogs; // id -> time
static constexpr uint32 CACHE_VERSION = 4;
uint32 cache_version = 0;
@ -1634,42 +1634,42 @@ class ContactsManager final : public Actor {
UserId support_user_id_;
int32 my_was_online_local_ = 0;
std::unordered_map<UserId, unique_ptr<User>, UserIdHash> users_;
std::unordered_map<UserId, unique_ptr<UserFull>, UserIdHash> users_full_;
std::unordered_map<UserId, UserPhotos, UserIdHash> user_photos_;
FlatHashMap<UserId, unique_ptr<User>, UserIdHash> users_;
FlatHashMap<UserId, unique_ptr<UserFull>, UserIdHash> users_full_;
FlatHashMap<UserId, UserPhotos, UserIdHash> user_photos_;
mutable std::unordered_set<UserId, UserIdHash> unknown_users_;
std::unordered_map<UserId, tl_object_ptr<telegram_api::UserProfilePhoto>, UserIdHash> pending_user_photos_;
FlatHashMap<UserId, tl_object_ptr<telegram_api::UserProfilePhoto>, UserIdHash> pending_user_photos_;
struct UserIdPhotoIdHash {
std::size_t operator()(const std::pair<UserId, int64> &pair) const {
return UserIdHash()(pair.first) * 2023654985u + std::hash<int64>()(pair.second);
}
};
std::unordered_map<std::pair<UserId, int64>, FileSourceId, UserIdPhotoIdHash> user_profile_photo_file_source_ids_;
std::unordered_map<int64, FileId> my_photo_file_id_;
FlatHashMap<std::pair<UserId, int64>, FileSourceId, UserIdPhotoIdHash> user_profile_photo_file_source_ids_;
FlatHashMap<int64, FileId> my_photo_file_id_;
std::unordered_map<ChatId, unique_ptr<Chat>, ChatIdHash> chats_;
std::unordered_map<ChatId, unique_ptr<ChatFull>, ChatIdHash> chats_full_;
FlatHashMap<ChatId, unique_ptr<Chat>, ChatIdHash> chats_;
FlatHashMap<ChatId, unique_ptr<ChatFull>, ChatIdHash> chats_full_;
mutable std::unordered_set<ChatId, ChatIdHash> unknown_chats_;
std::unordered_map<ChatId, FileSourceId, ChatIdHash> chat_full_file_source_ids_;
FlatHashMap<ChatId, FileSourceId, ChatIdHash> chat_full_file_source_ids_;
std::unordered_map<ChannelId, unique_ptr<MinChannel>, ChannelIdHash> min_channels_;
std::unordered_map<ChannelId, unique_ptr<Channel>, ChannelIdHash> channels_;
std::unordered_map<ChannelId, unique_ptr<ChannelFull>, ChannelIdHash> channels_full_;
FlatHashMap<ChannelId, unique_ptr<MinChannel>, ChannelIdHash> min_channels_;
FlatHashMap<ChannelId, unique_ptr<Channel>, ChannelIdHash> channels_;
FlatHashMap<ChannelId, unique_ptr<ChannelFull>, ChannelIdHash> channels_full_;
mutable std::unordered_set<ChannelId, ChannelIdHash> unknown_channels_;
std::unordered_set<ChannelId, ChannelIdHash> invalidated_channels_full_;
std::unordered_map<ChannelId, FileSourceId, ChannelIdHash> channel_full_file_source_ids_;
FlatHashMap<ChannelId, FileSourceId, ChannelIdHash> channel_full_file_source_ids_;
std::unordered_map<SecretChatId, unique_ptr<SecretChat>, SecretChatIdHash> secret_chats_;
FlatHashMap<SecretChatId, unique_ptr<SecretChat>, SecretChatIdHash> secret_chats_;
mutable std::unordered_set<SecretChatId, SecretChatIdHash> unknown_secret_chats_;
std::unordered_map<UserId, vector<SecretChatId>, UserIdHash> secret_chats_with_user_;
FlatHashMap<UserId, vector<SecretChatId>, UserIdHash> secret_chats_with_user_;
struct DialogAccessByInviteLink {
std::unordered_set<string> invite_links;
int32 accessible_before = 0;
};
std::unordered_map<string, unique_ptr<InviteLinkInfo>> invite_link_infos_;
std::unordered_map<DialogId, DialogAccessByInviteLink, DialogIdHash> dialog_access_by_invite_link_;
FlatHashMap<string, unique_ptr<InviteLinkInfo>> invite_link_infos_;
FlatHashMap<DialogId, DialogAccessByInviteLink, DialogIdHash> dialog_access_by_invite_link_;
bool created_public_channels_inited_[2] = {false, false};
vector<ChannelId> created_public_channels_[2];
@ -1681,28 +1681,28 @@ class ContactsManager final : public Actor {
bool inactive_channels_inited_ = false;
vector<ChannelId> inactive_channels_;
std::unordered_map<UserId, vector<Promise<Unit>>, UserIdHash> load_user_from_database_queries_;
FlatHashMap<UserId, vector<Promise<Unit>>, UserIdHash> load_user_from_database_queries_;
std::unordered_set<UserId, UserIdHash> loaded_from_database_users_;
std::unordered_set<UserId, UserIdHash> unavailable_user_fulls_;
std::unordered_map<ChatId, vector<Promise<Unit>>, ChatIdHash> load_chat_from_database_queries_;
FlatHashMap<ChatId, vector<Promise<Unit>>, ChatIdHash> load_chat_from_database_queries_;
std::unordered_set<ChatId, ChatIdHash> loaded_from_database_chats_;
std::unordered_set<ChatId, ChatIdHash> unavailable_chat_fulls_;
std::unordered_map<ChannelId, vector<Promise<Unit>>, ChannelIdHash> load_channel_from_database_queries_;
FlatHashMap<ChannelId, vector<Promise<Unit>>, ChannelIdHash> load_channel_from_database_queries_;
std::unordered_set<ChannelId, ChannelIdHash> loaded_from_database_channels_;
std::unordered_set<ChannelId, ChannelIdHash> unavailable_channel_fulls_;
std::unordered_map<SecretChatId, vector<Promise<Unit>>, SecretChatIdHash> load_secret_chat_from_database_queries_;
FlatHashMap<SecretChatId, vector<Promise<Unit>>, SecretChatIdHash> load_secret_chat_from_database_queries_;
std::unordered_set<SecretChatId, SecretChatIdHash> loaded_from_database_secret_chats_;
QueryCombiner get_user_full_queries_{"GetUserFullCombiner", 2.0};
QueryCombiner get_chat_full_queries_{"GetChatFullCombiner", 2.0};
std::unordered_map<DialogId, vector<DialogAdministrator>, DialogIdHash> dialog_administrators_;
FlatHashMap<DialogId, vector<DialogAdministrator>, DialogIdHash> dialog_administrators_;
std::unordered_map<DialogId, vector<SuggestedAction>, DialogIdHash> dialog_suggested_actions_;
std::unordered_map<DialogId, vector<Promise<Unit>>, DialogIdHash> dismiss_suggested_action_queries_;
FlatHashMap<DialogId, vector<SuggestedAction>, DialogIdHash> dialog_suggested_actions_;
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> dismiss_suggested_action_queries_;
class UploadProfilePhotoCallback;
std::shared_ptr<UploadProfilePhotoCallback> upload_profile_photo_callback_;
@ -1720,7 +1720,7 @@ class ContactsManager final : public Actor {
, promise(std::move(promise)) {
}
};
std::unordered_map<FileId, UploadedProfilePhoto, FileIdHash> uploaded_profile_photos_; // file_id -> promise
FlatHashMap<FileId, UploadedProfilePhoto, FileIdHash> uploaded_profile_photos_; // file_id -> promise
struct ImportContactsTask {
Promise<Unit> promise_;
@ -1728,11 +1728,11 @@ class ContactsManager final : public Actor {
vector<UserId> imported_user_ids_;
vector<int32> unimported_contact_invites_;
};
std::unordered_map<int64, unique_ptr<ImportContactsTask>> import_contact_tasks_;
FlatHashMap<int64, unique_ptr<ImportContactsTask>> import_contact_tasks_;
std::unordered_map<int64, std::pair<vector<UserId>, vector<int32>>> imported_contacts_;
FlatHashMap<int64, std::pair<vector<UserId>, vector<int32>>> imported_contacts_;
std::unordered_map<ChannelId, vector<DialogParticipant>, ChannelIdHash> cached_channel_participants_;
FlatHashMap<ChannelId, vector<DialogParticipant>, ChannelIdHash> cached_channel_participants_;
// bot-administrators only
struct ChannelParticipantInfo {
@ -1743,7 +1743,7 @@ class ContactsManager final : public Actor {
struct ChannelParticipants {
std::unordered_map<DialogId, ChannelParticipantInfo, DialogIdHash> participants_;
};
std::unordered_map<ChannelId, ChannelParticipants, ChannelIdHash> channel_participants_;
FlatHashMap<ChannelId, ChannelParticipants, ChannelIdHash> channel_participants_;
bool are_contacts_loaded_ = false;
int32 next_contacts_sync_date_ = 0;
@ -1771,7 +1771,7 @@ class ContactsManager final : public Actor {
bool is_set_location_visibility_request_sent_ = false;
Location last_user_location_;
std::unordered_map<ChannelId, ChannelId, ChannelIdHash> linked_channel_ids_;
FlatHashMap<ChannelId, ChannelId, ChannelIdHash> linked_channel_ids_;
std::unordered_set<UserId, UserIdHash> restricted_user_ids_;
std::unordered_set<ChannelId, ChannelIdHash> restricted_channel_ids_;

View File

@ -537,6 +537,6 @@ const CountryInfoManager::CountryList *CountryInfoManager::get_country_list(Coun
int32 CountryInfoManager::manager_count_ = 0;
std::mutex CountryInfoManager::country_mutex_;
std::unordered_map<string, unique_ptr<CountryInfoManager::CountryList>> CountryInfoManager::countries_;
FlatHashMap<string, unique_ptr<CountryInfoManager::CountryList>> CountryInfoManager::countries_;
} // namespace td

View File

@ -17,7 +17,7 @@
#include "td/utils/Status.h"
#include <mutex>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -76,9 +76,9 @@ class CountryInfoManager final : public Actor {
static int32 manager_count_;
static std::unordered_map<string, unique_ptr<CountryList>> countries_;
static FlatHashMap<string, unique_ptr<CountryList>> countries_;
std::unordered_map<string, vector<Promise<Unit>>> pending_load_country_queries_;
FlatHashMap<string, vector<Promise<Unit>>> pending_load_country_queries_;
Td *td_;
ActorShared<> parent_;

View File

@ -455,7 +455,7 @@ bool DialogFilter::are_flags_equal(const DialogFilter &lhs, const DialogFilter &
lhs.include_groups == rhs.include_groups && lhs.include_channels == rhs.include_channels;
}
std::unordered_map<string, string> DialogFilter::emoji_to_icon_name_;
std::unordered_map<string, string> DialogFilter::icon_name_to_emoji_;
FlatHashMap<string, string> DialogFilter::emoji_to_icon_name_;
FlatHashMap<string, string> DialogFilter::icon_name_to_emoji_;
} // namespace td

View File

@ -15,7 +15,7 @@
#include "td/utils/Status.h"
#include "td/utils/StringBuilder.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -75,8 +75,8 @@ class DialogFilter {
static bool are_flags_equal(const DialogFilter &lhs, const DialogFilter &rhs);
private:
static std::unordered_map<string, string> emoji_to_icon_name_;
static std::unordered_map<string, string> icon_name_to_emoji_;
static FlatHashMap<string, string> emoji_to_icon_name_;
static FlatHashMap<string, string> icon_name_to_emoji_;
static void init_icon_names();

View File

@ -19,7 +19,7 @@
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -125,7 +125,7 @@ class DocumentsManager {
FileId on_get_document(unique_ptr<GeneralDocument> new_document, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<GeneralDocument>, FileIdHash> documents_; // file_id -> GeneralDocument
FlatHashMap<FileId, unique_ptr<GeneralDocument>, FileIdHash> documents_; // file_id -> GeneralDocument
};
} // namespace td

View File

@ -25,7 +25,7 @@
#include "td/utils/Status.h"
#include "td/utils/Variant.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -150,7 +150,7 @@ class FileReferenceManager final : public Actor {
int64 query_generation_{0};
std::unordered_map<NodeId, Node, FileIdHash> nodes_;
FlatHashMap<NodeId, Node, FileIdHash> nodes_;
void run_node(NodeId node);
void send_query(Destination dest, FileSourceId file_source_id);

View File

@ -26,7 +26,7 @@
#include <atomic>
#include <memory>
#include <mutex>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
class AnimationsManager;
@ -492,7 +492,7 @@ class Global final : public ActorContext {
static int64 get_location_key(double latitude, double longitude);
std::unordered_map<int64, int64> location_access_hashes_;
FlatHashMap<int64, int64> location_access_hashes_;
int32 to_unix_time(double server_time) const;

View File

@ -883,7 +883,7 @@ struct GroupCallManager::GroupCallParticipants {
vector<DialogId> administrator_dialog_ids;
struct PendingUpdates {
std::unordered_map<DialogId, GroupCallParticipant, DialogIdHash> updates;
FlatHashMap<DialogId, GroupCallParticipant, DialogIdHash> updates;
};
std::map<int32, PendingUpdates> pending_version_updates_;
std::map<int32, PendingUpdates> pending_mute_updates_;

View File

@ -23,7 +23,7 @@
#include "td/utils/common.h"
#include "td/utils/Status.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -381,21 +381,21 @@ class GroupCallManager final : public Actor {
vector<InputGroupCallId> input_group_call_ids_;
std::unordered_map<InputGroupCallId, unique_ptr<GroupCall>, InputGroupCallIdHash> group_calls_;
FlatHashMap<InputGroupCallId, unique_ptr<GroupCall>, InputGroupCallIdHash> group_calls_;
string pending_group_call_join_params_;
std::unordered_map<InputGroupCallId, unique_ptr<GroupCallParticipants>, InputGroupCallIdHash>
FlatHashMap<InputGroupCallId, unique_ptr<GroupCallParticipants>, InputGroupCallIdHash>
group_call_participants_;
std::unordered_map<DialogId, vector<InputGroupCallId>, DialogIdHash> participant_id_to_group_call_id_;
FlatHashMap<DialogId, vector<InputGroupCallId>, DialogIdHash> participant_id_to_group_call_id_;
std::unordered_map<GroupCallId, unique_ptr<GroupCallRecentSpeakers>, GroupCallIdHash> group_call_recent_speakers_;
FlatHashMap<GroupCallId, unique_ptr<GroupCallRecentSpeakers>, GroupCallIdHash> group_call_recent_speakers_;
std::unordered_map<InputGroupCallId, vector<Promise<td_api::object_ptr<td_api::groupCall>>>, InputGroupCallIdHash>
FlatHashMap<InputGroupCallId, vector<Promise<td_api::object_ptr<td_api::groupCall>>>, InputGroupCallIdHash>
load_group_call_queries_;
std::unordered_map<InputGroupCallId, unique_ptr<PendingJoinRequest>, InputGroupCallIdHash> pending_join_requests_;
std::unordered_map<InputGroupCallId, unique_ptr<PendingJoinRequest>, InputGroupCallIdHash>
FlatHashMap<InputGroupCallId, unique_ptr<PendingJoinRequest>, InputGroupCallIdHash> pending_join_requests_;
FlatHashMap<InputGroupCallId, unique_ptr<PendingJoinRequest>, InputGroupCallIdHash>
pending_join_presentation_requests_;
uint64 join_group_request_generation_ = 0;

View File

@ -25,7 +25,7 @@
#include "td/utils/common.h"
#include "td/utils/Status.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -141,12 +141,12 @@ class InlineQueriesManager final : public Actor {
};
MultiTimeout drop_inline_query_result_timeout_{"DropInlineQueryResultTimeout"};
std::unordered_map<uint64, InlineQueryResult> inline_query_results_; // query_hash -> result
FlatHashMap<uint64, InlineQueryResult> inline_query_results_; // query_hash -> result
std::unordered_map<int64, std::unordered_map<string, InlineMessageContent>>
FlatHashMap<int64, FlatHashMap<string, InlineMessageContent>>
inline_message_contents_; // query_id -> [result_id -> inline_message_content]
std::unordered_map<int64, UserId> query_id_to_bot_user_id_;
FlatHashMap<int64, UserId> query_id_to_bot_user_id_;
Td *td_;
ActorShared<> parent_;

View File

@ -51,8 +51,8 @@ struct LanguagePackManager::Language {
bool was_loaded_full_ = false;
bool has_get_difference_query_ = false;
vector<Promise<Unit>> get_difference_queries_;
std::unordered_map<string, string> ordinary_strings_;
std::unordered_map<string, PluralizedString> pluralized_strings_;
FlatHashMap<string, string> ordinary_strings_;
FlatHashMap<string, PluralizedString> pluralized_strings_;
std::unordered_set<string> deleted_strings_;
SqliteKeyValue kv_; // usages should be guarded by database_->mutex_
};
@ -84,15 +84,15 @@ struct LanguagePackManager::LanguagePack {
SqliteKeyValue pack_kv_; // usages should be guarded by database_->mutex_
std::map<string, LanguageInfo> custom_language_pack_infos_; // sorted by language_code
vector<std::pair<string, LanguageInfo>> server_language_pack_infos_; // sorted by server
std::unordered_map<string, LanguageInfo> all_server_language_pack_infos_;
std::unordered_map<string, unique_ptr<Language>> languages_;
FlatHashMap<string, LanguageInfo> all_server_language_pack_infos_;
FlatHashMap<string, unique_ptr<Language>> languages_;
};
struct LanguagePackManager::LanguageDatabase {
std::mutex mutex_;
string path_;
SqliteDb database_;
std::unordered_map<string, unique_ptr<LanguagePack>> language_packs_;
FlatHashMap<string, unique_ptr<LanguagePack>> language_packs_;
};
LanguagePackManager::~LanguagePackManager() = default;
@ -774,11 +774,19 @@ td_api::object_ptr<td_api::languagePackString> LanguagePackManager::get_language
const std::pair<string, string> &str) {
return td_api::make_object<td_api::languagePackString>(str.first, get_language_pack_string_value_object(str.second));
}
td_api::object_ptr<td_api::languagePackString> LanguagePackManager::get_language_pack_string_object(
const string &a, const string &b) {
return td_api::make_object<td_api::languagePackString>(a, get_language_pack_string_value_object(b));
}
td_api::object_ptr<td_api::languagePackString> LanguagePackManager::get_language_pack_string_object(
const std::pair<string, PluralizedString> &str) {
return td_api::make_object<td_api::languagePackString>(str.first, get_language_pack_string_value_object(str.second));
}
td_api::object_ptr<td_api::languagePackString> LanguagePackManager::get_language_pack_string_object(
const string &a, const PluralizedString &b) {
return td_api::make_object<td_api::languagePackString>(a, get_language_pack_string_value_object(b));
}
td_api::object_ptr<td_api::languagePackString> LanguagePackManager::get_language_pack_string_object(const string &str) {
return td_api::make_object<td_api::languagePackString>(str, get_language_pack_string_value_object());
@ -812,10 +820,10 @@ td_api::object_ptr<td_api::languagePackStrings> LanguagePackManager::get_languag
vector<td_api::object_ptr<td_api::languagePackString>> strings;
if (keys.empty()) {
for (auto &str : language->ordinary_strings_) {
strings.push_back(get_language_pack_string_object(str));
strings.push_back(get_language_pack_string_object(str.first, str.second));
}
for (auto &str : language->pluralized_strings_) {
strings.push_back(get_language_pack_string_object(str));
strings.push_back(get_language_pack_string_object(str.first, str.second));
}
} else {
for (auto &key : keys) {
@ -1377,7 +1385,7 @@ void LanguagePackManager::on_get_language_pack_strings(
key_count_delta -= static_cast<int32>(language->pluralized_strings_.erase(str->key_));
language->deleted_strings_.erase(str->key_);
if (is_diff) {
strings.push_back(get_language_pack_string_object(*it));
strings.push_back(get_language_pack_string_object(it->first, it->second));
}
database_strings.emplace_back(std::move(str->key_), PSTRING() << '1' << it->second);
break;
@ -1397,7 +1405,7 @@ void LanguagePackManager::on_get_language_pack_strings(
key_count_delta -= static_cast<int32>(language->ordinary_strings_.erase(str->key_));
language->deleted_strings_.erase(str->key_);
if (is_diff) {
strings.push_back(get_language_pack_string_object(*it));
strings.push_back(get_language_pack_string_object(it->first, it->second));
}
database_strings.emplace_back(
std::move(str->key_), PSTRING()
@ -1876,6 +1884,6 @@ void LanguagePackManager::hangup() {
int32 LanguagePackManager::manager_count_ = 0;
std::mutex LanguagePackManager::language_database_mutex_;
std::unordered_map<string, unique_ptr<LanguagePackManager::LanguageDatabase>> LanguagePackManager::language_databases_;
FlatHashMap<string, unique_ptr<LanguagePackManager::LanguageDatabase>> LanguagePackManager::language_databases_;
} // namespace td

View File

@ -19,7 +19,7 @@
#include "td/utils/Status.h"
#include <mutex>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -100,12 +100,12 @@ class LanguagePackManager final : public NetQueryCallback {
vector<Promise<td_api::object_ptr<td_api::languagePackStrings>>> queries_;
};
std::unordered_map<string, std::unordered_map<string, PendingQueries>> get_all_language_pack_strings_queries_;
FlatHashMap<string, FlatHashMap<string, PendingQueries>> get_all_language_pack_strings_queries_;
static int32 manager_count_;
static std::mutex language_database_mutex_;
static std::unordered_map<string, unique_ptr<LanguageDatabase>> language_databases_;
static FlatHashMap<string, unique_ptr<LanguageDatabase>> language_databases_;
static LanguageDatabase *add_language_database(string path);
@ -127,8 +127,12 @@ class LanguagePackManager final : public NetQueryCallback {
static td_api::object_ptr<td_api::languagePackString> get_language_pack_string_object(
const std::pair<string, string> &str);
static td_api::object_ptr<td_api::languagePackString> get_language_pack_string_object(
const string &, const string &);
static td_api::object_ptr<td_api::languagePackString> get_language_pack_string_object(
const std::pair<string, PluralizedString> &str);
static td_api::object_ptr<td_api::languagePackString> get_language_pack_string_object(
const string &, const PluralizedString &);
static td_api::object_ptr<td_api::languagePackString> get_language_pack_string_object(const string &str);
static td_api::object_ptr<td_api::LanguagePackStringValue> get_language_pack_string_value_object(

View File

@ -371,7 +371,7 @@ void MessageReactions::update_from(const MessageReactions &old_reactions) {
}
}
void MessageReactions::sort_reactions(const std::unordered_map<string, size_t> &active_reaction_pos) {
void MessageReactions::sort_reactions(const FlatHashMap<string, size_t> &active_reaction_pos) {
std::sort(reactions_.begin(), reactions_.end(),
[&active_reaction_pos](const MessageReaction &lhs, const MessageReaction &rhs) {
if (lhs.get_choose_count() != rhs.get_choose_count()) {

View File

@ -19,7 +19,7 @@
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -147,7 +147,7 @@ struct MessageReactions {
void update_from(const MessageReactions &old_reactions);
void sort_reactions(const std::unordered_map<string, size_t> &active_reaction_pos);
void sort_reactions(const FlatHashMap<string, size_t> &active_reaction_pos);
static bool need_update_message_reactions(const MessageReactions *old_reactions,
const MessageReactions *new_reactions);

View File

@ -1,6 +1,4 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@ -83,7 +81,7 @@
#include <limits>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -8115,9 +8113,9 @@ void MessagesManager::update_scope_unmute_timeout(NotificationSettingsScope scop
auto is_muted = new_mute_until != 0;
if (was_muted != is_muted) {
if (G()->parameters().use_message_db) {
std::unordered_map<DialogListId, int32, DialogListIdHash> delta;
std::unordered_map<DialogListId, int32, DialogListIdHash> total_count;
std::unordered_map<DialogListId, int32, DialogListIdHash> marked_count;
FlatHashMap<DialogListId, int32, DialogListIdHash> delta;
FlatHashMap<DialogListId, int32, DialogListIdHash> total_count;
FlatHashMap<DialogListId, int32, DialogListIdHash> marked_count;
std::unordered_set<DialogListId, DialogListIdHash> dialog_list_ids;
for (auto &dialog : dialogs_) {
Dialog *d = dialog.second.get();
@ -10319,7 +10317,7 @@ void MessagesManager::on_get_scheduled_server_messages(DialogId dialog_id, uint3
vector<MessageId> old_message_ids;
find_old_messages(d->scheduled_messages.get(),
MessageId(ScheduledServerMessageId(), std::numeric_limits<int32>::max(), true), old_message_ids);
std::unordered_map<ScheduledServerMessageId, MessageId, ScheduledServerMessageIdHash> old_server_message_ids;
FlatHashMap<ScheduledServerMessageId, MessageId, ScheduledServerMessageIdHash> old_server_message_ids;
for (auto &message_id : old_message_ids) {
if (message_id.is_scheduled_server()) {
old_server_message_ids[message_id.get_scheduled_server_message_id()] = message_id;
@ -10433,8 +10431,8 @@ void MessagesManager::on_get_message_public_forwards(int32 total_count,
}
void MessagesManager::delete_messages_from_updates(const vector<MessageId> &message_ids) {
std::unordered_map<DialogId, vector<int64>, DialogIdHash> deleted_message_ids;
std::unordered_map<DialogId, bool, DialogIdHash> need_update_dialog_pos;
FlatHashMap<DialogId, vector<int64>, DialogIdHash> deleted_message_ids;
FlatHashMap<DialogId, bool, DialogIdHash> need_update_dialog_pos;
for (auto message_id : message_ids) {
if (!message_id.is_valid() || !message_id.is_server()) {
LOG(ERROR) << "Incoming update tries to delete " << message_id;
@ -12865,7 +12863,7 @@ void MessagesManager::ttl_period_unregister_message(DialogId dialog_id, const Me
}
void MessagesManager::ttl_loop(double now) {
std::unordered_map<DialogId, std::vector<MessageId>, DialogIdHash> to_delete;
FlatHashMap<DialogId, std::vector<MessageId>, DialogIdHash> to_delete;
while (!ttl_heap_.empty() && ttl_heap_.top_key() < now) {
TtlNode *ttl_node = TtlNode::from_heap_node(ttl_heap_.pop());
auto full_message_id = ttl_node->full_message_id_;
@ -15141,8 +15139,8 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector<tl_object_ptr<te
} else {
LOG(INFO) << "Process " << dialogs.size() << " chats out of " << total_count << " in " << folder_id;
}
std::unordered_map<FullMessageId, DialogDate, FullMessageIdHash> full_message_id_to_dialog_date;
std::unordered_map<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
FlatHashMap<FullMessageId, DialogDate, FullMessageIdHash> full_message_id_to_dialog_date;
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
for (auto &message : messages) {
auto full_message_id = get_full_message_id(message, false);
if (from_dialog_list) {
@ -16964,7 +16962,7 @@ void MessagesManager::on_get_dialog_filters(Result<vector<tl_object_ptr<telegram
if (server_dialog_filters_ != new_server_dialog_filters) {
LOG(INFO) << "Change server chat filters from " << get_dialog_filter_ids(server_dialog_filters_) << " to "
<< get_dialog_filter_ids(new_server_dialog_filters);
std::unordered_map<DialogFilterId, const DialogFilter *, DialogFilterIdHash> old_server_dialog_filters;
FlatHashMap<DialogFilterId, const DialogFilter *, DialogFilterIdHash> old_server_dialog_filters;
for (const auto &filter : server_dialog_filters_) {
old_server_dialog_filters.emplace(filter->dialog_filter_id, filter.get());
}
@ -18274,8 +18272,8 @@ void MessagesManager::get_messages_from_server(vector<FullMessageId> &&message_i
}
vector<tl_object_ptr<telegram_api::InputMessage>> ordinary_message_ids;
std::unordered_map<ChannelId, vector<tl_object_ptr<telegram_api::InputMessage>>, ChannelIdHash> channel_message_ids;
std::unordered_map<DialogId, vector<int32>, DialogIdHash> scheduled_message_ids;
FlatHashMap<ChannelId, vector<tl_object_ptr<telegram_api::InputMessage>>, ChannelIdHash> channel_message_ids;
FlatHashMap<DialogId, vector<int32>, DialogIdHash> scheduled_message_ids;
for (auto &full_message_id : message_ids) {
auto dialog_id = full_message_id.get_dialog_id();
auto message_id = full_message_id.get_message_id();
@ -27862,8 +27860,8 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
auto &copied_messages = result.copied_messages;
auto &forwarded_message_contents = result.forwarded_message_contents;
std::unordered_map<int64, std::pair<int64, int32>> new_copied_media_album_ids;
std::unordered_map<int64, std::pair<int64, int32>> new_forwarded_media_album_ids;
FlatHashMap<int64, std::pair<int64, int32>> new_copied_media_album_ids;
FlatHashMap<int64, std::pair<int64, int32>> new_forwarded_media_album_ids;
for (size_t i = 0; i < message_ids.size(); i++) {
MessageId message_id = get_persistent_message_id(from_dialog, message_ids[i]);
@ -28129,7 +28127,7 @@ Result<vector<MessageId>> MessagesManager::resend_messages(DialogId dialog_id, v
}
vector<unique_ptr<MessageContent>> new_contents(message_ids.size());
std::unordered_map<int64, std::pair<int64, int32>> new_media_album_ids;
FlatHashMap<int64, std::pair<int64, int32>> new_media_album_ids;
for (size_t i = 0; i < message_ids.size(); i++) {
MessageId message_id = message_ids[i];
const Message *m = get_message(d, message_id);
@ -36574,7 +36572,7 @@ bool MessagesManager::set_dialog_order(Dialog *d, int64 new_order, bool need_sen
}
void MessagesManager::update_dialog_lists(
Dialog *d, std::unordered_map<DialogListId, DialogPositionInList, DialogListIdHash> &&old_positions,
Dialog *d, FlatHashMap<DialogListId, DialogPositionInList, DialogListIdHash> &&old_positions,
bool need_send_update, bool is_loaded_from_database, const char *source) {
if (td_->auth_manager_->is_bot()) {
return;
@ -37173,10 +37171,10 @@ MessagesManager::DialogPositionInList MessagesManager::get_dialog_position_in_li
return position;
}
std::unordered_map<DialogListId, MessagesManager::DialogPositionInList, DialogListIdHash>
FlatHashMap<DialogListId, MessagesManager::DialogPositionInList, DialogListIdHash>
MessagesManager::get_dialog_positions(const Dialog *d) const {
CHECK(d != nullptr);
std::unordered_map<DialogListId, MessagesManager::DialogPositionInList, DialogListIdHash> positions;
FlatHashMap<DialogListId, MessagesManager::DialogPositionInList, DialogListIdHash> positions;
if (!td_->auth_manager_->is_bot()) {
for (const auto &dialog_list : dialog_lists_) {
positions.emplace(dialog_list.first, get_dialog_position_in_list(&dialog_list.second, d));
@ -37656,7 +37654,7 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m
int32 unread_mention_count, int32 unread_reaction_count,
MessageId read_outbox_max_message_id,
vector<tl_object_ptr<telegram_api::Message>> &&messages) {
std::unordered_map<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
for (auto &message : messages) {
auto message_id = get_message_id(message, false);
auto message_dialog_id = get_message_dialog_id(message);

View File

@ -73,12 +73,14 @@
#include "td/utils/Status.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/FlatHashMap.h"
#include <array>
#include <functional>
#include <map>
#include <memory>
#include <set>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -1231,7 +1233,7 @@ class MessagesManager final : public Actor {
unique_ptr<DialogActionBar> action_bar;
LogEventIdWithGeneration save_draft_message_log_event_id;
LogEventIdWithGeneration save_notification_settings_log_event_id;
std::unordered_map<int64, LogEventIdWithGeneration> read_history_log_event_ids;
FlatHashMap<int64, LogEventIdWithGeneration> read_history_log_event_ids;
std::unordered_set<MessageId, MessageIdHash> updated_read_history_message_ids;
LogEventIdWithGeneration set_folder_id_log_event_id;
InputGroupCallId active_group_call_id;
@ -1328,20 +1330,20 @@ class MessagesManager final : public Actor {
int32 pending_read_channel_inbox_pts = 0; // for channels only
int32 pending_read_channel_inbox_server_unread_count = 0; // for channels only
MessageId pending_read_channel_inbox_max_message_id; // for channels only
std::unordered_map<int64, MessageId> random_id_to_message_id; // for secret chats only
FlatHashMap<int64, MessageId> random_id_to_message_id; // for secret chats only
MessageId last_assigned_message_id; // identifier of the last local or yet unsent message, assigned after
// application start, used to guarantee that all assigned message identifiers
// are different
std::unordered_map<MessageId, std::set<MessageId>, MessageIdHash>
FlatHashMap<MessageId, std::set<MessageId>, MessageIdHash>
yet_unsent_thread_message_ids; // top_thread_message_id -> yet unsent message IDs
std::unordered_map<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date;
FlatHashMap<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date;
std::unordered_map<MessageId, MessageId, MessageIdHash> yet_unsent_message_id_to_persistent_message_id;
FlatHashMap<MessageId, MessageId, MessageIdHash> yet_unsent_message_id_to_persistent_message_id;
std::unordered_map<int32, MessageId> last_assigned_scheduled_message_id; // date -> message_id
FlatHashMap<int32, MessageId> last_assigned_scheduled_message_id; // date -> message_id
std::unordered_set<MessageId, MessageIdHash> deleted_message_ids;
std::unordered_set<ScheduledServerMessageId, ScheduledServerMessageIdHash> deleted_scheduled_server_message_ids;
@ -1349,7 +1351,7 @@ class MessagesManager final : public Actor {
std::vector<std::pair<DialogId, MessageId>> pending_new_message_notifications;
std::vector<std::pair<DialogId, MessageId>> pending_new_mention_notifications;
std::unordered_map<NotificationId, MessageId, NotificationIdHash> notification_id_to_message_id;
FlatHashMap<NotificationId, MessageId, NotificationIdHash> notification_id_to_message_id;
string client_data;
@ -1359,7 +1361,7 @@ class MessagesManager final : public Actor {
MessageId suffix_load_query_message_id_;
std::vector<std::pair<Promise<>, std::function<bool(const Message *)>>> suffix_load_queries_;
std::unordered_map<MessageId, int64, MessageIdHash> pending_viewed_live_locations; // message_id -> task_id
FlatHashMap<MessageId, int64, MessageIdHash> pending_viewed_live_locations; // message_id -> task_id
std::unordered_set<MessageId, MessageIdHash> pending_viewed_message_ids;
unique_ptr<Message> messages;
@ -1437,7 +1439,7 @@ class MessagesManager final : public Actor {
vector<Promise<Unit>> load_list_queries_;
std::unordered_map<DialogId, int64, DialogIdHash> pinned_dialog_id_orders_;
FlatHashMap<DialogId, int64, DialogIdHash> pinned_dialog_id_orders_;
vector<DialogDate> pinned_dialogs_;
bool are_pinned_dialogs_inited_ = false;
@ -2773,7 +2775,7 @@ class MessagesManager final : public Actor {
DialogPositionInList get_dialog_position_in_list(const DialogList *list, const Dialog *d, bool actual = false) const;
std::unordered_map<DialogListId, DialogPositionInList, DialogListIdHash> get_dialog_positions(const Dialog *d) const;
FlatHashMap<DialogListId, DialogPositionInList, DialogListIdHash> get_dialog_positions(const Dialog *d) const;
static vector<DialogListId> get_dialog_list_ids(const Dialog *d);
@ -3021,7 +3023,7 @@ class MessagesManager final : public Actor {
const char *source);
void update_dialog_lists(Dialog *d,
std::unordered_map<DialogListId, DialogPositionInList, DialogListIdHash> &&old_positions,
FlatHashMap<DialogListId, DialogPositionInList, DialogListIdHash> &&old_positions,
bool need_send_update, bool is_loaded_from_database, const char *source);
void update_last_dialog_date(FolderId folder_id);
@ -3270,20 +3272,20 @@ class MessagesManager final : public Actor {
double last_channel_pts_jump_warning_time_ = 0;
std::unordered_map<FileId, std::pair<FullMessageId, FileId>, FileIdHash>
FlatHashMap<FileId, std::pair<FullMessageId, FileId>, FileIdHash>
being_uploaded_files_; // file_id -> message, thumbnail_file_id
struct UploadedThumbnailInfo {
FullMessageId full_message_id;
FileId file_id; // original file file_id
tl_object_ptr<telegram_api::InputFile> input_file; // original file InputFile
};
std::unordered_map<FileId, UploadedThumbnailInfo, FileIdHash> being_uploaded_thumbnails_; // thumbnail_file_id -> ...
FlatHashMap<FileId, UploadedThumbnailInfo, FileIdHash> being_uploaded_thumbnails_; // thumbnail_file_id -> ...
struct UploadedSecretThumbnailInfo {
FullMessageId full_message_id;
FileId file_id; // original file file_id
tl_object_ptr<telegram_api::InputEncryptedFile> input_file; // original file InputEncryptedFile
};
std::unordered_map<FileId, UploadedSecretThumbnailInfo, FileIdHash>
FlatHashMap<FileId, UploadedSecretThumbnailInfo, FileIdHash>
being_loaded_secret_thumbnails_; // thumbnail_file_id -> ...
// TTL
@ -3322,11 +3324,11 @@ class MessagesManager final : public Actor {
bool ttl_db_has_query_;
Slot ttl_db_slot_;
std::unordered_map<int64, FullMessageId> being_sent_messages_; // message_random_id -> message
FlatHashMap<int64, FullMessageId> being_sent_messages_; // message_random_id -> message
std::unordered_map<FullMessageId, MessageId, FullMessageIdHash>
FlatHashMap<FullMessageId, MessageId, FullMessageIdHash>
update_message_ids_; // new_message_id -> temporary_id
std::unordered_map<DialogId, std::unordered_map<ScheduledServerMessageId, MessageId, ScheduledServerMessageIdHash>,
FlatHashMap<DialogId, FlatHashMap<ScheduledServerMessageId, MessageId, ScheduledServerMessageIdHash>,
DialogIdHash>
update_scheduled_message_ids_; // new_message_id -> temporary_id
@ -3348,7 +3350,7 @@ class MessagesManager final : public Actor {
, promise(std::move(promise)) {
}
};
std::unordered_map<FileId, UploadedDialogPhotoInfo, FileIdHash> being_uploaded_dialog_photos_;
FlatHashMap<FileId, UploadedDialogPhotoInfo, FileIdHash> being_uploaded_dialog_photos_;
struct UploadedImportedMessagesInfo {
DialogId dialog_id;
@ -3364,7 +3366,7 @@ class MessagesManager final : public Actor {
, promise(std::move(promise)) {
}
};
std::unordered_map<FileId, unique_ptr<UploadedImportedMessagesInfo>, FileIdHash> being_uploaded_imported_messages_;
FlatHashMap<FileId, unique_ptr<UploadedImportedMessagesInfo>, FileIdHash> being_uploaded_imported_messages_;
struct UploadedImportedMessageAttachmentInfo {
DialogId dialog_id;
@ -3377,7 +3379,7 @@ class MessagesManager final : public Actor {
: dialog_id(dialog_id), import_id(import_id), is_reupload(is_reupload), promise(std::move(promise)) {
}
};
std::unordered_map<FileId, unique_ptr<UploadedImportedMessageAttachmentInfo>, FileIdHash>
FlatHashMap<FileId, unique_ptr<UploadedImportedMessageAttachmentInfo>, FileIdHash>
being_uploaded_imported_message_attachments_;
struct PendingMessageImport {
@ -3386,7 +3388,7 @@ class MessagesManager final : public Actor {
int64 import_id = 0;
Promise<Unit> promise;
};
std::unordered_map<int64, unique_ptr<PendingMessageImport>> pending_message_imports_;
FlatHashMap<int64, unique_ptr<PendingMessageImport>> pending_message_imports_;
struct PendingMessageGroupSend {
DialogId dialog_id;
@ -3395,20 +3397,20 @@ class MessagesManager final : public Actor {
vector<bool> is_finished;
vector<Status> results;
};
std::unordered_map<int64, PendingMessageGroupSend> pending_message_group_sends_; // media_album_id -> ...
FlatHashMap<int64, PendingMessageGroupSend> pending_message_group_sends_; // media_album_id -> ...
std::unordered_map<MessageId, DialogId, MessageIdHash> message_id_to_dialog_id_;
std::unordered_map<MessageId, DialogId, MessageIdHash> last_clear_history_message_id_to_dialog_id_;
FlatHashMap<MessageId, DialogId, MessageIdHash> message_id_to_dialog_id_;
FlatHashMap<MessageId, DialogId, MessageIdHash> last_clear_history_message_id_to_dialog_id_;
bool created_public_broadcasts_inited_ = false;
vector<ChannelId> created_public_broadcasts_;
std::unordered_map<int64, DialogId> created_dialogs_; // random_id -> dialog_id
std::unordered_map<DialogId, Promise<Unit>, DialogIdHash> pending_created_dialogs_; // dialog_id -> promise
FlatHashMap<int64, DialogId> created_dialogs_; // random_id -> dialog_id
FlatHashMap<DialogId, Promise<Unit>, DialogIdHash> pending_created_dialogs_; // dialog_id -> promise
bool running_get_difference_ = false; // true after before_get_difference and false after after_get_difference
std::unordered_map<DialogId, unique_ptr<Dialog>, DialogIdHash> dialogs_;
FlatHashMap<DialogId, unique_ptr<Dialog>, DialogIdHash> dialogs_;
std::unordered_set<DialogId, DialogIdHash>
loaded_dialogs_; // dialogs loaded from database, but not added to dialogs_
@ -3426,9 +3428,9 @@ class MessagesManager final : public Actor {
}
};
std::unordered_map<string, vector<Promise<Unit>>> search_public_dialogs_queries_;
std::unordered_map<string, vector<DialogId>> found_public_dialogs_; // TODO time bound cache
std::unordered_map<string, vector<DialogId>> found_on_server_dialogs_; // TODO time bound cache
FlatHashMap<string, vector<Promise<Unit>>> search_public_dialogs_queries_;
FlatHashMap<string, vector<DialogId>> found_public_dialogs_; // TODO time bound cache
FlatHashMap<string, vector<DialogId>> found_on_server_dialogs_; // TODO time bound cache
struct CommonDialogs {
vector<DialogId> dialog_ids;
@ -3436,35 +3438,35 @@ class MessagesManager final : public Actor {
int32 total_count = 0;
bool is_outdated = false;
};
std::unordered_map<UserId, CommonDialogs, UserIdHash> found_common_dialogs_;
FlatHashMap<UserId, CommonDialogs, UserIdHash> found_common_dialogs_;
std::unordered_map<int64, FullMessageId> get_dialog_message_by_date_results_;
FlatHashMap<int64, FullMessageId> get_dialog_message_by_date_results_;
std::unordered_map<int64, td_api::object_ptr<td_api::messageCalendar>> found_dialog_message_calendars_;
std::unordered_map<int64, std::pair<int32, vector<MessageId>>>
FlatHashMap<int64, td_api::object_ptr<td_api::messageCalendar>> found_dialog_message_calendars_;
FlatHashMap<int64, std::pair<int32, vector<MessageId>>>
found_dialog_messages_; // random_id -> [total_count, [message_id]...]
std::unordered_map<int64, DialogId> found_dialog_messages_dialog_id_; // random_id -> dialog_id
std::unordered_map<int64, std::pair<int32, vector<FullMessageId>>>
FlatHashMap<int64, DialogId> found_dialog_messages_dialog_id_; // random_id -> dialog_id
FlatHashMap<int64, std::pair<int32, vector<FullMessageId>>>
found_messages_; // random_id -> [total_count, [full_message_id]...]
std::unordered_map<int64, std::pair<int32, vector<FullMessageId>>>
FlatHashMap<int64, std::pair<int32, vector<FullMessageId>>>
found_call_messages_; // random_id -> [total_count, [full_message_id]...]
std::unordered_map<int64, FoundMessages> found_fts_messages_; // random_id -> FoundMessages
FlatHashMap<int64, FoundMessages> found_fts_messages_; // random_id -> FoundMessages
struct MessageEmbeddingCodes {
std::unordered_map<MessageId, string, MessageIdHash> embedding_codes_;
FlatHashMap<MessageId, string, MessageIdHash> embedding_codes_;
};
std::unordered_map<DialogId, MessageEmbeddingCodes, DialogIdHash> message_embedding_codes_[2];
FlatHashMap<DialogId, MessageEmbeddingCodes, DialogIdHash> message_embedding_codes_[2];
std::unordered_map<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_notification_settings_queries_;
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_notification_settings_queries_;
std::unordered_map<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_queries_;
std::unordered_map<DialogId, uint64, DialogIdHash> get_dialog_query_log_event_id_;
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_queries_;
FlatHashMap<DialogId, uint64, DialogIdHash> get_dialog_query_log_event_id_;
std::unordered_map<FullMessageId, int32, FullMessageIdHash> replied_by_yet_unsent_messages_;
FlatHashMap<FullMessageId, int32, FullMessageIdHash> replied_by_yet_unsent_messages_;
// full_message_id -> replies with media timestamps
std::unordered_map<FullMessageId, std::unordered_set<MessageId, MessageIdHash>, FullMessageIdHash>
FlatHashMap<FullMessageId, std::unordered_set<MessageId, MessageIdHash>, FullMessageIdHash>
replied_by_media_timestamp_messages_;
struct ActiveDialogAction {
@ -3482,13 +3484,13 @@ class MessagesManager final : public Actor {
}
};
std::unordered_map<DialogId, std::vector<ActiveDialogAction>, DialogIdHash> active_dialog_actions_;
FlatHashMap<DialogId, std::vector<ActiveDialogAction>, DialogIdHash> active_dialog_actions_;
ScopeNotificationSettings users_notification_settings_;
ScopeNotificationSettings chats_notification_settings_;
ScopeNotificationSettings channels_notification_settings_;
std::unordered_map<NotificationGroupId, DialogId, NotificationGroupIdHash> notification_group_id_to_dialog_id_;
FlatHashMap<NotificationGroupId, DialogId, NotificationGroupIdHash> notification_group_id_to_dialog_id_;
uint64 current_message_edit_generation_ = 0;
@ -3497,8 +3499,8 @@ class MessagesManager final : public Actor {
int64 current_pinned_dialog_order_ = static_cast<int64>(MIN_PINNED_DIALOG_DATE) << 32;
std::unordered_map<DialogListId, DialogList, DialogListIdHash> dialog_lists_;
std::unordered_map<FolderId, DialogFolder, FolderIdHash> dialog_folders_;
FlatHashMap<DialogListId, DialogList, DialogListIdHash> dialog_lists_;
FlatHashMap<FolderId, DialogFolder, FolderIdHash> dialog_folders_;
bool are_dialog_filters_being_synchronized_ = false;
bool are_dialog_filters_being_reloaded_ = false;
@ -3511,10 +3513,10 @@ class MessagesManager final : public Actor {
vector<RecommendedDialogFilter> recommended_dialog_filters_;
vector<Promise<Unit>> dialog_filter_reload_queries_;
std::unordered_map<DialogId, string, DialogIdHash> active_get_channel_differencies_;
std::unordered_map<DialogId, uint64, DialogIdHash> get_channel_difference_to_log_event_id_;
std::unordered_map<DialogId, int32, DialogIdHash> channel_get_difference_retry_timeouts_;
std::unordered_map<DialogId, std::multimap<int32, PendingPtsUpdate>, DialogIdHash> postponed_channel_updates_;
FlatHashMap<DialogId, string, DialogIdHash> active_get_channel_differencies_;
FlatHashMap<DialogId, uint64, DialogIdHash> get_channel_difference_to_log_event_id_;
FlatHashMap<DialogId, int32, DialogIdHash> channel_get_difference_retry_timeouts_;
FlatHashMap<DialogId, std::multimap<int32, PendingPtsUpdate>, DialogIdHash> postponed_channel_updates_;
std::unordered_set<DialogId, DialogIdHash> is_channel_difference_finished_;
MultiTimeout channel_get_difference_timeout_{"ChannelGetDifferenceTimeout"};
@ -3539,15 +3541,15 @@ class MessagesManager final : public Actor {
bool are_active_live_location_messages_loaded_ = false;
vector<Promise<Unit>> load_active_live_location_messages_queries_;
std::unordered_map<DialogId, vector<Promise<Unit>>, DialogIdHash> load_scheduled_messages_from_database_queries_;
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> load_scheduled_messages_from_database_queries_;
struct ResolvedUsername {
DialogId dialog_id;
double expires_at;
};
std::unordered_map<string, ResolvedUsername> resolved_usernames_;
std::unordered_map<string, DialogId> inaccessible_resolved_usernames_;
FlatHashMap<string, ResolvedUsername> resolved_usernames_;
FlatHashMap<string, DialogId> inaccessible_resolved_usernames_;
std::unordered_set<string> reload_voice_chat_on_search_usernames_;
struct GetDialogsTask {
@ -3558,7 +3560,7 @@ class MessagesManager final : public Actor {
Promise<td_api::object_ptr<td_api::chats>> promise;
};
std::unordered_map<int64, GetDialogsTask> get_dialogs_tasks_;
FlatHashMap<int64, GetDialogsTask> get_dialogs_tasks_;
int64 current_get_dialogs_task_id_ = 0;
struct PendingOnGetDialogs {
@ -3570,27 +3572,27 @@ class MessagesManager final : public Actor {
};
vector<PendingOnGetDialogs> pending_on_get_dialogs_;
std::unordered_map<DialogId, PendingOnGetDialogs, DialogIdHash> pending_channel_on_get_dialogs_;
FlatHashMap<DialogId, PendingOnGetDialogs, DialogIdHash> pending_channel_on_get_dialogs_;
std::unordered_map<DialogId, vector<Promise<Unit>>, DialogIdHash> run_after_get_channel_difference_;
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> run_after_get_channel_difference_;
ChangesProcessor<unique_ptr<PendingSecretMessage>> pending_secret_messages_;
std::unordered_map<DialogId, vector<DialogId>, DialogIdHash>
FlatHashMap<DialogId, vector<DialogId>, DialogIdHash>
pending_add_dialog_last_database_message_dependent_dialogs_;
std::unordered_map<DialogId, std::pair<int32, unique_ptr<Message>>, DialogIdHash>
FlatHashMap<DialogId, std::pair<int32, unique_ptr<Message>>, DialogIdHash>
pending_add_dialog_last_database_message_; // dialog -> dependency counter + message
std::unordered_map<DialogId, vector<DialogId>, DialogIdHash>
FlatHashMap<DialogId, vector<DialogId>, DialogIdHash>
pending_add_default_join_group_call_as_dialog_id_; // dialog_id -> dependent dialogs
std::unordered_map<DialogId, vector<std::pair<DialogId, bool>>, DialogIdHash>
FlatHashMap<DialogId, vector<std::pair<DialogId, bool>>, DialogIdHash>
pending_add_default_send_message_as_dialog_id_; // dialog_id -> [dependent dialog, need_drop]
struct MessageIds {
std::unordered_set<MessageId, MessageIdHash> message_ids;
};
std::unordered_map<DialogId, MessageIds, DialogIdHash> dialog_bot_command_message_ids_;
FlatHashMap<DialogId, MessageIds, DialogIdHash> dialog_bot_command_message_ids_;
struct CallsDbState {
std::array<MessageId, 2> first_calls_database_message_id_by_index;
@ -3606,15 +3608,15 @@ class MessagesManager final : public Actor {
CallsDbState calls_db_state_;
int64 viewed_live_location_task_id_ = 0;
std::unordered_map<int64, FullMessageId> viewed_live_location_tasks_; // task_id -> task
FlatHashMap<int64, FullMessageId> viewed_live_location_tasks_; // task_id -> task
std::unordered_map<uint64, std::map<MessageId, Promise<Message *>>> yet_unsent_media_queues_;
FlatHashMap<uint64, std::map<MessageId, Promise<Message *>>> yet_unsent_media_queues_;
std::unordered_map<DialogId, NetQueryRef, DialogIdHash> set_typing_query_;
FlatHashMap<DialogId, NetQueryRef, DialogIdHash> set_typing_query_;
std::unordered_map<FullMessageId, FileSourceId, FullMessageIdHash> full_message_id_to_file_source_id_;
FlatHashMap<FullMessageId, FileSourceId, FullMessageIdHash> full_message_id_to_file_source_id_;
std::unordered_map<DialogId, int32, DialogIdHash> last_outgoing_forwarded_message_date_;
FlatHashMap<DialogId, int32, DialogIdHash> last_outgoing_forwarded_message_date_;
struct OnlineMemberCountInfo {
int32 online_member_count = 0;
@ -3622,22 +3624,22 @@ class MessagesManager final : public Actor {
bool is_update_sent = false;
};
std::unordered_map<DialogId, OnlineMemberCountInfo, DialogIdHash> dialog_online_member_counts_;
FlatHashMap<DialogId, OnlineMemberCountInfo, DialogIdHash> dialog_online_member_counts_;
std::unordered_map<DialogId, std::pair<bool, bool>, DialogIdHash> pending_dialog_group_call_updates_;
FlatHashMap<DialogId, std::pair<bool, bool>, DialogIdHash> pending_dialog_group_call_updates_;
std::unordered_map<string, int32> auth_notification_id_date_;
FlatHashMap<string, int32> auth_notification_id_date_;
std::unordered_map<DialogId, MessageId, DialogIdHash> previous_repaired_read_inbox_max_message_id_;
FlatHashMap<DialogId, MessageId, DialogIdHash> previous_repaired_read_inbox_max_message_id_;
struct PendingReaction {
int32 query_count = 0;
bool was_updated = false;
};
std::unordered_map<FullMessageId, PendingReaction, FullMessageIdHash> pending_reactions_;
FlatHashMap<FullMessageId, PendingReaction, FullMessageIdHash> pending_reactions_;
vector<string> active_reactions_;
std::unordered_map<string, size_t> active_reaction_pos_;
FlatHashMap<string, size_t> active_reaction_pos_;
uint32 scheduled_messages_sync_generation_ = 1;

View File

@ -61,7 +61,7 @@
#include <algorithm>
#include <iterator>
#include <limits>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
namespace td {
@ -1075,8 +1075,8 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour
is_changed = false;
size_t cur_pos = 0;
std::unordered_map<int32, size_t> first_add_notification_pos;
std::unordered_map<int32, size_t> first_edit_notification_pos;
FlatHashMap<int32, size_t> first_add_notification_pos;
FlatHashMap<int32, size_t> first_edit_notification_pos;
std::unordered_set<int32> can_be_deleted_notification_ids;
std::vector<int32> moved_deleted_notification_ids;
size_t first_notification_group_pos = 0;

View File

@ -31,7 +31,7 @@
#include <functional>
#include <map>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
namespace td {
@ -375,19 +375,19 @@ class NotificationManager final : public Actor {
std::unordered_set<int32> running_get_chat_difference_;
NotificationGroups groups_;
std::unordered_map<NotificationGroupId, NotificationGroupKey, NotificationGroupIdHash> group_keys_;
FlatHashMap<NotificationGroupId, NotificationGroupKey, NotificationGroupIdHash> group_keys_;
std::unordered_map<int32, vector<td_api::object_ptr<td_api::Update>>> pending_updates_;
FlatHashMap<int32, vector<td_api::object_ptr<td_api::Update>>> pending_updates_;
MultiTimeout flush_pending_notifications_timeout_{"FlushPendingNotificationsTimeout"};
MultiTimeout flush_pending_updates_timeout_{"FlushPendingUpdatesTimeout"};
vector<NotificationGroupId> call_notification_group_ids_;
std::unordered_set<NotificationGroupId, NotificationGroupIdHash> available_call_notification_group_ids_;
std::unordered_map<DialogId, NotificationGroupId, DialogIdHash> dialog_id_to_call_notification_group_id_;
FlatHashMap<DialogId, NotificationGroupId, DialogIdHash> dialog_id_to_call_notification_group_id_;
std::unordered_map<NotificationId, uint64, NotificationIdHash> temporary_notification_log_event_ids_;
std::unordered_map<NotificationId, uint64, NotificationIdHash> temporary_edit_notification_log_event_ids_;
FlatHashMap<NotificationId, uint64, NotificationIdHash> temporary_notification_log_event_ids_;
FlatHashMap<NotificationId, uint64, NotificationIdHash> temporary_edit_notification_log_event_ids_;
struct TemporaryNotification {
NotificationGroupId group_id;
NotificationId notification_id;
@ -396,17 +396,17 @@ class NotificationManager final : public Actor {
string sender_name;
bool is_outgoing;
};
std::unordered_map<FullMessageId, TemporaryNotification, FullMessageIdHash> temporary_notifications_;
std::unordered_map<NotificationId, FullMessageId, NotificationIdHash> temporary_notification_message_ids_;
std::unordered_map<NotificationId, vector<Promise<Unit>>, NotificationIdHash> push_notification_promises_;
FlatHashMap<FullMessageId, TemporaryNotification, FullMessageIdHash> temporary_notifications_;
FlatHashMap<NotificationId, FullMessageId, NotificationIdHash> temporary_notification_message_ids_;
FlatHashMap<NotificationId, vector<Promise<Unit>>, NotificationIdHash> push_notification_promises_;
struct ActiveCallNotification {
CallId call_id;
NotificationId notification_id;
};
std::unordered_map<DialogId, vector<ActiveCallNotification>, DialogIdHash> active_call_notifications_;
FlatHashMap<DialogId, vector<ActiveCallNotification>, DialogIdHash> active_call_notifications_;
std::unordered_map<int32, int32> announcement_id_date_;
FlatHashMap<int32, int32> announcement_id_date_;
Td *td_;
ActorShared<> parent_;

View File

@ -44,7 +44,7 @@
#include <algorithm>
#include <limits>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -441,7 +441,7 @@ vector<int32> PollManager::get_vote_percentage(const vector<int32> &voter_counts
int32 pos = -1;
int32 count = 0;
};
std::unordered_map<int32, Option> options;
FlatHashMap<int32, Option> options;
for (size_t i = 0; i < result.size(); i++) {
auto &option = options[voter_counts[i]];
if (option.pos == -1) {
@ -703,7 +703,7 @@ void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id,
return promise.set_error(Status::Error(400, "Can't revote in a quiz"));
}
std::unordered_map<size_t, int> affected_option_ids;
FlatHashMap<size_t, int> affected_option_ids;
vector<string> options;
for (auto &option_id : option_ids) {
auto index = static_cast<size_t>(option_id);
@ -722,7 +722,7 @@ void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id,
affected_option_ids[option_index]++;
}
}
for (auto it : affected_option_ids) {
for (const auto &it : affected_option_ids) {
if (it.second == 1) {
invalidate_poll_option_voters(poll, poll_id, it.first);
}

View File

@ -23,7 +23,7 @@
#include "td/utils/common.h"
#include "td/utils/Status.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -207,9 +207,9 @@ class PollManager final : public Actor {
Td *td_;
ActorShared<> parent_;
std::unordered_map<PollId, unique_ptr<Poll>, PollIdHash> polls_;
FlatHashMap<PollId, unique_ptr<Poll>, PollIdHash> polls_;
std::unordered_map<PollId, std::unordered_set<FullMessageId, FullMessageIdHash>, PollIdHash> poll_messages_;
FlatHashMap<PollId, std::unordered_set<FullMessageId, FullMessageIdHash>, PollIdHash> poll_messages_;
struct PendingPollAnswer {
vector<string> options_;
@ -218,9 +218,9 @@ class PollManager final : public Actor {
uint64 log_event_id_ = 0;
NetQueryRef query_ref_;
};
std::unordered_map<PollId, PendingPollAnswer, PollIdHash> pending_answers_;
FlatHashMap<PollId, PendingPollAnswer, PollIdHash> pending_answers_;
std::unordered_map<PollId, vector<PollOptionVoters>, PollIdHash> poll_voters_;
FlatHashMap<PollId, vector<PollOptionVoters>, PollIdHash> poll_voters_;
int64 current_local_poll_id_ = 0;

View File

@ -14,7 +14,7 @@
#include "td/utils/Status.h"
#include <queue>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -39,7 +39,7 @@ class QueryCombiner final : public Actor {
std::queue<int64> delayed_queries_;
std::unordered_map<int64, QueryInfo> queries_;
FlatHashMap<int64, QueryInfo> queries_;
void do_send_query(int64 query_id, QueryInfo &query);

View File

@ -21,7 +21,7 @@
#include "td/utils/Status.h"
#include <map>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -77,7 +77,7 @@ class SecureManager final : public NetQueryCallback {
vector<telegram_api::object_ptr<telegram_api::SecureValueError>> errors;
};
std::unordered_map<int32, AuthorizationForm> authorization_forms_;
FlatHashMap<int32, AuthorizationForm> authorization_forms_;
int32 max_authorization_form_id_{0};
void hangup() final;

View File

@ -15,7 +15,7 @@
#include "td/utils/Slice.h"
#include <limits>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -86,7 +86,7 @@ class MultiSequenceDispatcherOld final : public SequenceDispatcher::Parent {
int32 cnt_;
ActorOwn<SequenceDispatcher> dispatcher_;
};
std::unordered_map<uint64, Data> dispatchers_;
FlatHashMap<uint64, Data> dispatchers_;
void on_result() final;
void ready_to_close() final;
};

View File

@ -111,7 +111,7 @@ struct SponsoredMessageManager::SponsoredMessage {
struct SponsoredMessageManager::DialogSponsoredMessages {
vector<Promise<td_api::object_ptr<td_api::sponsoredMessage>>> promises;
vector<SponsoredMessage> messages;
std::unordered_map<int64, string> message_random_ids;
FlatHashMap<int64, string> message_random_ids;
};
SponsoredMessageManager::SponsoredMessageManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {

View File

@ -18,7 +18,7 @@
#include "td/utils/common.h"
#include "td/utils/Status.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -58,7 +58,7 @@ class SponsoredMessageManager final : public Actor {
void on_get_dialog_sponsored_messages(
DialogId dialog_id, Result<telegram_api::object_ptr<telegram_api::messages_sponsoredMessages>> &&result);
std::unordered_map<DialogId, unique_ptr<DialogSponsoredMessages>, DialogIdHash> dialog_sponsored_messages_;
FlatHashMap<DialogId, unique_ptr<DialogSponsoredMessages>, DialogIdHash> dialog_sponsored_messages_;
MessageId current_sponsored_message_id_ = MessageId::max();

View File

@ -3025,7 +3025,7 @@ StickerSetId StickersManager::on_get_messages_sticker_set(StickerSetId sticker_s
vector<tl_object_ptr<telegram_api::stickerPack>> packs = std::move(set->packs_);
vector<tl_object_ptr<telegram_api::Document>> documents = std::move(set->documents_);
std::unordered_map<int64, FileId> document_id_to_sticker_id;
FlatHashMap<int64, FileId> document_id_to_sticker_id;
s->sticker_ids.clear();
bool is_bot = td_->auth_manager_->is_bot();
@ -3037,7 +3037,7 @@ StickerSetId StickersManager::on_get_messages_sticker_set(StickerSetId sticker_s
s->sticker_ids.push_back(sticker_id.second);
if (!is_bot) {
document_id_to_sticker_id.insert(sticker_id);
document_id_to_sticker_id.emplace(sticker_id.first, sticker_id.second);
}
}
if (static_cast<int32>(s->sticker_ids.size()) != s->sticker_count) {
@ -4850,7 +4850,7 @@ void StickersManager::schedule_update_animated_emoji_clicked(const StickerSet *s
}
auto all_sticker_ids = get_animated_emoji_click_stickers(sticker_set, emoji);
std::unordered_map<int, FileId> sticker_ids;
FlatHashMap<int, FileId> sticker_ids;
for (auto sticker_id : all_sticker_ids) {
auto it = sticker_set->sticker_emojis_map_.find(sticker_id);
if (it != sticker_set->sticker_emojis_map_.end()) {
@ -7435,7 +7435,7 @@ void StickersManager::on_get_emoji_keywords_difference(
keywords->version_ = version;
}
version = keywords->version_;
std::unordered_map<string, string> key_values;
FlatHashMap<string, string> key_values;
key_values.emplace(get_emoji_language_code_version_database_key(language_code), to_string(version));
key_values.emplace(get_emoji_language_code_last_difference_time_database_key(language_code),
to_string(G()->unix_time()));

View File

@ -31,7 +31,7 @@
#include <memory>
#include <tuple>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -374,8 +374,8 @@ class StickersManager final : public Actor {
PhotoSize thumbnail;
vector<FileId> sticker_ids;
std::unordered_map<string, vector<FileId>> emoji_stickers_map_; // emoji -> stickers
std::unordered_map<FileId, vector<string>, FileIdHash> sticker_emojis_map_; // sticker -> emojis
FlatHashMap<string, vector<FileId>> emoji_stickers_map_; // emoji -> stickers
FlatHashMap<FileId, vector<string>, FileIdHash> sticker_emojis_map_; // sticker -> emojis
bool is_installed = false;
bool is_archived = false;
@ -758,9 +758,9 @@ class StickersManager final : public Actor {
bool is_inited_ = false;
std::unordered_map<FileId, unique_ptr<Sticker>, FileIdHash> stickers_; // file_id -> Sticker
std::unordered_map<StickerSetId, unique_ptr<StickerSet>, StickerSetIdHash> sticker_sets_; // id -> StickerSet
std::unordered_map<string, StickerSetId> short_name_to_sticker_set_id_;
FlatHashMap<FileId, unique_ptr<Sticker>, FileIdHash> stickers_; // file_id -> Sticker
FlatHashMap<StickerSetId, unique_ptr<StickerSet>, StickerSetIdHash> sticker_sets_; // id -> StickerSet
FlatHashMap<string, StickerSetId> short_name_to_sticker_set_id_;
vector<StickerSetId> installed_sticker_set_ids_[2];
vector<StickerSetId> featured_sticker_set_ids_;
@ -808,7 +808,7 @@ class StickersManager final : public Actor {
vector<StickerSetId> archived_sticker_set_ids_[2];
int32 total_archived_sticker_set_count_[2] = {-1, -1};
std::unordered_map<FileId, vector<StickerSetId>, FileIdHash> attached_sticker_sets_;
FlatHashMap<FileId, vector<StickerSetId>, FileIdHash> attached_sticker_sets_;
Hints installed_sticker_sets_hints_[2]; // search installed sticker sets by their title and name
@ -817,11 +817,11 @@ class StickersManager final : public Actor {
int32 cache_time_ = 300;
double next_reload_time_ = 0;
};
std::unordered_map<string, FoundStickers> found_stickers_;
std::unordered_map<string, vector<Promise<Unit>>> search_stickers_queries_;
FlatHashMap<string, FoundStickers> found_stickers_;
FlatHashMap<string, vector<Promise<Unit>>> search_stickers_queries_;
std::unordered_map<string, vector<StickerSetId>> found_sticker_sets_;
std::unordered_map<string, vector<Promise<Unit>>> search_sticker_sets_queries_;
FlatHashMap<string, vector<StickerSetId>> found_sticker_sets_;
FlatHashMap<string, vector<Promise<Unit>>> search_sticker_sets_queries_;
std::unordered_set<StickerSetId, StickerSetIdHash> pending_viewed_featured_sticker_set_ids_;
Timeout pending_featured_sticker_set_views_timeout_;
@ -829,7 +829,7 @@ class StickersManager final : public Actor {
int32 recent_stickers_limit_ = 200;
int32 favorite_stickers_limit_ = 5;
std::unordered_map<SpecialStickerSetType, SpecialStickerSet, SpecialStickerSetTypeHash> special_sticker_sets_;
FlatHashMap<SpecialStickerSetType, SpecialStickerSet, SpecialStickerSetTypeHash> special_sticker_sets_;
struct StickerSetLoadRequest {
Promise<Unit> promise;
@ -837,14 +837,14 @@ class StickersManager final : public Actor {
size_t left_queries = 0;
};
std::unordered_map<uint32, StickerSetLoadRequest> sticker_set_load_requests_;
FlatHashMap<uint32, StickerSetLoadRequest> sticker_set_load_requests_;
uint32 current_sticker_set_load_request_ = 0;
std::unordered_map<int64, unique_ptr<PendingNewStickerSet>> pending_new_sticker_sets_;
FlatHashMap<int64, unique_ptr<PendingNewStickerSet>> pending_new_sticker_sets_;
std::unordered_map<int64, unique_ptr<PendingAddStickerToSet>> pending_add_sticker_to_sets_;
FlatHashMap<int64, unique_ptr<PendingAddStickerToSet>> pending_add_sticker_to_sets_;
std::unordered_map<int64, unique_ptr<PendingSetStickerSetThumbnail>> pending_set_sticker_set_thumbnails_;
FlatHashMap<int64, unique_ptr<PendingSetStickerSetThumbnail>> pending_set_sticker_set_thumbnails_;
vector<Promise<Unit>> pending_get_animated_emoji_queries_;
@ -866,26 +866,26 @@ class StickersManager final : public Actor {
std::shared_ptr<UploadStickerFileCallback> upload_sticker_file_callback_;
std::unordered_map<FileId, std::pair<UserId, Promise<Unit>>, FileIdHash> being_uploaded_files_;
FlatHashMap<FileId, std::pair<UserId, Promise<Unit>>, FileIdHash> being_uploaded_files_;
Reactions reactions_;
std::unordered_map<string, vector<string>> emoji_language_codes_;
std::unordered_map<string, int32> emoji_language_code_versions_;
std::unordered_map<string, double> emoji_language_code_last_difference_times_;
FlatHashMap<string, vector<string>> emoji_language_codes_;
FlatHashMap<string, int32> emoji_language_code_versions_;
FlatHashMap<string, double> emoji_language_code_last_difference_times_;
std::unordered_set<string> reloaded_emoji_keywords_;
std::unordered_map<string, vector<Promise<Unit>>> load_emoji_keywords_queries_;
std::unordered_map<string, vector<Promise<Unit>>> load_language_codes_queries_;
std::unordered_map<int64, string> emoji_suggestions_urls_;
FlatHashMap<string, vector<Promise<Unit>>> load_emoji_keywords_queries_;
FlatHashMap<string, vector<Promise<Unit>>> load_language_codes_queries_;
FlatHashMap<int64, string> emoji_suggestions_urls_;
std::unordered_map<string, std::unordered_set<FullMessageId, FullMessageIdHash>> dice_messages_;
FlatHashMap<string, std::unordered_set<FullMessageId, FullMessageIdHash>> dice_messages_;
struct EmojiMessages {
std::unordered_set<FullMessageId, FullMessageIdHash> full_message_ids;
std::pair<FileId, int> animated_emoji_sticker;
FileId sound_file_id;
};
std::unordered_map<string, EmojiMessages> emoji_messages_;
FlatHashMap<string, EmojiMessages> emoji_messages_;
string dice_emojis_str_;
vector<string> dice_emojis_;
@ -894,7 +894,7 @@ class StickersManager final : public Actor {
vector<std::pair<int32, int32>> dice_success_values_;
string emoji_sounds_str_;
std::unordered_map<string, FileId> emoji_sounds_;
FlatHashMap<string, FileId> emoji_sounds_;
double animated_emoji_zoom_ = 0.0;

View File

@ -31,7 +31,7 @@
#include "td/utils/Status.h"
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -284,7 +284,7 @@ class Td final : public Actor {
enum class State : int32 { WaitParameters, Decrypt, Run, Close } state_ = State::WaitParameters;
bool is_database_encrypted_ = false;
std::unordered_map<uint64, std::shared_ptr<ResultHandler>> result_handlers_;
FlatHashMap<uint64, std::shared_ptr<ResultHandler>> result_handlers_;
enum : int8 { RequestActorIdType = 1, ActorIdType = 2 };
Container<ActorOwn<Actor>> request_actors_;
@ -293,7 +293,7 @@ class Td final : public Actor {
NetQueryRef update_status_query_;
int64 alarm_id_ = 1;
std::unordered_map<int64, uint64> pending_alarms_;
FlatHashMap<int64, uint64> pending_alarms_;
MultiTimeout alarm_timeout_{"AlarmTimeout"};
TermsOfService pending_terms_of_service_;
@ -303,7 +303,7 @@ class Td final : public Actor {
int32 limit = -1;
vector<uint64> request_ids;
};
std::unordered_map<FileId, DownloadInfo, FileIdHash> pending_file_downloads_;
FlatHashMap<FileId, DownloadInfo, FileIdHash> pending_file_downloads_;
vector<std::pair<uint64, td_api::object_ptr<td_api::Function>>> pending_preauthentication_requests_;

View File

@ -15,7 +15,7 @@
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -70,7 +70,7 @@ class VideoNotesManager {
FileId on_get_video_note(unique_ptr<VideoNote> new_video_note, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<VideoNote>, FileIdHash> video_notes_;
FlatHashMap<FileId, unique_ptr<VideoNote>, FileIdHash> video_notes_;
};
} // namespace td

View File

@ -15,7 +15,7 @@
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -84,7 +84,7 @@ class VideosManager {
FileId on_get_video(unique_ptr<Video> new_video, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<Video>, FileIdHash> videos_;
FlatHashMap<FileId, unique_ptr<Video>, FileIdHash> videos_;
};
} // namespace td

View File

@ -13,7 +13,7 @@
#include "td/utils/common.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -61,7 +61,7 @@ class VoiceNotesManager {
FileId on_get_voice_note(unique_ptr<VoiceNote> new_voice_note, bool replace);
Td *td_;
std::unordered_map<FileId, unique_ptr<VoiceNote>, FileIdHash> voice_notes_;
FlatHashMap<FileId, unique_ptr<VoiceNote>, FileIdHash> voice_notes_;
};
} // namespace td

View File

@ -47,7 +47,7 @@ struct GetWebPageBlockObjectContext {
bool is_first_pass_ = true;
bool has_anchor_urls_ = false;
std::unordered_map<Slice, const RichText *, SliceHash> anchors_; // anchor -> text
FlatHashMap<Slice, const RichText *, SliceHash> anchors_; // anchor -> text
};
static vector<td_api::object_ptr<td_api::PageBlock>> get_page_block_objects(
@ -1763,10 +1763,10 @@ class WebPageBlockVoiceNote final : public WebPageBlock {
};
vector<RichText> get_rich_texts(vector<tl_object_ptr<telegram_api::RichText>> &&rich_text_ptrs,
const std::unordered_map<int64, FileId> &documents);
const FlatHashMap<int64, FileId> &documents);
RichText get_rich_text(tl_object_ptr<telegram_api::RichText> &&rich_text_ptr,
const std::unordered_map<int64, FileId> &documents) {
const FlatHashMap<int64, FileId> &documents) {
CHECK(rich_text_ptr != nullptr);
RichText result;
@ -1881,14 +1881,14 @@ RichText get_rich_text(tl_object_ptr<telegram_api::RichText> &&rich_text_ptr,
}
vector<RichText> get_rich_texts(vector<tl_object_ptr<telegram_api::RichText>> &&rich_text_ptrs,
const std::unordered_map<int64, FileId> &documents) {
const FlatHashMap<int64, FileId> &documents) {
return transform(std::move(rich_text_ptrs), [&documents](tl_object_ptr<telegram_api::RichText> &&rich_text) {
return get_rich_text(std::move(rich_text), documents);
});
}
WebPageBlockCaption get_page_block_caption(tl_object_ptr<telegram_api::pageCaption> &&page_caption,
const std::unordered_map<int64, FileId> &documents) {
const FlatHashMap<int64, FileId> &documents) {
CHECK(page_caption != nullptr);
WebPageBlockCaption result;
result.text = get_rich_text(std::move(page_caption->text_), documents);
@ -1897,12 +1897,12 @@ WebPageBlockCaption get_page_block_caption(tl_object_ptr<telegram_api::pageCapti
}
unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::PageBlock> page_block_ptr,
const std::unordered_map<int64, FileId> &animations,
const std::unordered_map<int64, FileId> &audios,
const std::unordered_map<int64, FileId> &documents,
const std::unordered_map<int64, Photo> &photos,
const std::unordered_map<int64, FileId> &videos,
const std::unordered_map<int64, FileId> &voice_notes) {
const FlatHashMap<int64, FileId> &animations,
const FlatHashMap<int64, FileId> &audios,
const FlatHashMap<int64, FileId> &documents,
const FlatHashMap<int64, Photo> &photos,
const FlatHashMap<int64, FileId> &videos,
const FlatHashMap<int64, FileId> &voice_notes) {
CHECK(page_block_ptr != nullptr);
switch (page_block_ptr->get_id()) {
case telegram_api::pageBlockUnsupported::ID:
@ -2368,9 +2368,9 @@ void parse(unique_ptr<WebPageBlock> &block, LogEventParser &parser) {
vector<unique_ptr<WebPageBlock>> get_web_page_blocks(
Td *td, vector<tl_object_ptr<telegram_api::PageBlock>> page_block_ptrs,
const std::unordered_map<int64, FileId> &animations, const std::unordered_map<int64, FileId> &audios,
const std::unordered_map<int64, FileId> &documents, const std::unordered_map<int64, Photo> &photos,
const std::unordered_map<int64, FileId> &videos, const std::unordered_map<int64, FileId> &voice_notes) {
const FlatHashMap<int64, FileId> &animations, const FlatHashMap<int64, FileId> &audios,
const FlatHashMap<int64, FileId> &documents, const FlatHashMap<int64, Photo> &photos,
const FlatHashMap<int64, FileId> &videos, const FlatHashMap<int64, FileId> &voice_notes) {
vector<unique_ptr<WebPageBlock>> result;
result.reserve(page_block_ptrs.size());
for (auto &page_block_ptr : page_block_ptrs) {

View File

@ -15,7 +15,7 @@
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -98,9 +98,9 @@ void parse(unique_ptr<WebPageBlock> &block, LogEventParser &parser);
vector<unique_ptr<WebPageBlock>> get_web_page_blocks(
Td *td, vector<tl_object_ptr<telegram_api::PageBlock>> page_block_ptrs,
const std::unordered_map<int64, FileId> &animations, const std::unordered_map<int64, FileId> &audios,
const std::unordered_map<int64, FileId> &documents, const std::unordered_map<int64, Photo> &photos,
const std::unordered_map<int64, FileId> &videos, const std::unordered_map<int64, FileId> &voice_notes);
const FlatHashMap<int64, FileId> &animations, const FlatHashMap<int64, FileId> &audios,
const FlatHashMap<int64, FileId> &documents, const FlatHashMap<int64, Photo> &photos,
const FlatHashMap<int64, FileId> &videos, const FlatHashMap<int64, FileId> &voice_notes);
vector<td_api::object_ptr<td_api::PageBlock>> get_page_block_objects(
const vector<unique_ptr<WebPageBlock>> &page_blocks, Td *td, Slice base_url);

View File

@ -1391,7 +1391,7 @@ void WebPagesManager::on_pending_web_page_timeout(WebPageId web_page_id) {
void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_ptr<telegram_api::page> &&page,
int32 hash, DialogId owner_dialog_id) {
CHECK(page != nullptr);
std::unordered_map<int64, Photo> photos;
FlatHashMap<int64, Photo> photos;
for (auto &photo_ptr : page->photos_) {
Photo photo = get_photo(td_->file_manager_.get(), std::move(photo_ptr), owner_dialog_id);
if (photo.is_empty() || photo.id.get() == 0) {
@ -1405,12 +1405,12 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_
photos.emplace(web_page->photo.id.get(), web_page->photo);
}
std::unordered_map<int64, FileId> animations;
std::unordered_map<int64, FileId> audios;
std::unordered_map<int64, FileId> documents;
std::unordered_map<int64, FileId> videos;
std::unordered_map<int64, FileId> voice_notes;
std::unordered_map<int64, FileId> others;
FlatHashMap<int64, FileId> animations;
FlatHashMap<int64, FileId> audios;
FlatHashMap<int64, FileId> documents;
FlatHashMap<int64, FileId> videos;
FlatHashMap<int64, FileId> voice_notes;
FlatHashMap<int64, FileId> others;
auto get_map = [&](Document::Type document_type) {
switch (document_type) {
case Document::Type::Animation:

View File

@ -22,7 +22,7 @@
#include "td/utils/common.h"
#include "td/utils/Status.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -179,28 +179,28 @@ class WebPagesManager final : public Actor {
Td *td_;
ActorShared<> parent_;
std::unordered_map<WebPageId, unique_ptr<WebPage>, WebPageIdHash> web_pages_;
FlatHashMap<WebPageId, unique_ptr<WebPage>, WebPageIdHash> web_pages_;
std::unordered_map<WebPageId, vector<Promise<Unit>>, WebPageIdHash> load_web_page_from_database_queries_;
FlatHashMap<WebPageId, vector<Promise<Unit>>, WebPageIdHash> load_web_page_from_database_queries_;
std::unordered_set<WebPageId, WebPageIdHash> loaded_from_database_web_pages_;
struct PendingWebPageInstantViewQueries {
vector<Promise<WebPageId>> partial;
vector<Promise<WebPageId>> full;
};
std::unordered_map<WebPageId, PendingWebPageInstantViewQueries, WebPageIdHash> load_web_page_instant_view_queries_;
FlatHashMap<WebPageId, PendingWebPageInstantViewQueries, WebPageIdHash> load_web_page_instant_view_queries_;
std::unordered_map<WebPageId, std::unordered_set<FullMessageId, FullMessageIdHash>, WebPageIdHash> web_page_messages_;
FlatHashMap<WebPageId, std::unordered_set<FullMessageId, FullMessageIdHash>, WebPageIdHash> web_page_messages_;
std::unordered_map<WebPageId, std::unordered_map<int64, std::pair<string, Promise<Unit>>>, WebPageIdHash>
FlatHashMap<WebPageId, FlatHashMap<int64, std::pair<string, Promise<Unit>>>, WebPageIdHash>
pending_get_web_pages_;
int64 get_web_page_preview_request_id_ = 1;
std::unordered_map<int64, WebPageId> got_web_page_previews_;
FlatHashMap<int64, WebPageId> got_web_page_previews_;
std::unordered_map<string, WebPageId> url_to_web_page_id_;
FlatHashMap<string, WebPageId> url_to_web_page_id_;
std::unordered_map<string, FileSourceId> url_to_file_source_id_;
FlatHashMap<string, FileSourceId> url_to_file_source_id_;
MultiTimeout pending_web_pages_timeout_{"PendingWebPagesTimeout"};
};

View File

@ -63,7 +63,7 @@
#include <memory>
#include <queue>
#include <tuple>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -228,8 +228,8 @@ class CliClient final : public Actor {
yield();
}
std::unordered_map<uint64, SendMessageInfo> query_id_to_send_message_info_;
std::unordered_map<uint64, SendMessageInfo> message_id_to_send_message_info_;
FlatHashMap<uint64, SendMessageInfo> query_id_to_send_message_info_;
FlatHashMap<uint64, SendMessageInfo> message_id_to_send_message_info_;
struct User {
string first_name;
@ -237,8 +237,8 @@ class CliClient final : public Actor {
string username;
};
std::unordered_map<int64, User> users_;
std::unordered_map<string, int64> username_to_user_id_;
FlatHashMap<int64, User> users_;
FlatHashMap<string, int64> username_to_user_id_;
vector<string> authentication_tokens_;
@ -269,7 +269,7 @@ class CliClient final : public Actor {
}
}
std::unordered_map<string, int64> username_to_supergroup_id_;
FlatHashMap<string, int64> username_to_supergroup_id_;
void register_supergroup(const td_api::supergroup &supergroup) {
if (!supergroup.username_.empty()) {
username_to_supergroup_id_[to_lower(supergroup.username_)] = supergroup.id_;
@ -4708,7 +4708,7 @@ class CliClient final : public Actor {
return res;
}
std::unordered_map<int32, double> being_downloaded_files_;
FlatHashMap<int32, double> being_downloaded_files_;
int64 my_id_ = 0;
td_api::object_ptr<td_api::AuthorizationState> authorization_state_;

View File

@ -36,7 +36,7 @@
#include <map>
#include <memory>
#include <set>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -566,7 +566,7 @@ class FileManager final : public FileLoadManager::Callback {
};
Enumerator<RemoteInfo> remote_location_info_;
std::unordered_map<string, FileId> file_hash_to_file_id_;
FlatHashMap<string, FileId> file_hash_to_file_id_;
std::map<FullLocalFileLocation, FileId> local_location_to_file_id_;
std::map<FullGenerateFileLocation, FileId> generate_location_to_file_id_;

View File

@ -112,19 +112,22 @@ void FileStats::apply_dialog_ids(const vector<DialogId> &dialog_ids) {
std::unordered_set<DialogId, DialogIdHash> all_dialogs(dialog_ids.begin(), dialog_ids.end());
StatByType other_stats;
bool other_flag = false;
for (auto it = stat_by_owner_dialog_id_.begin(); it != stat_by_owner_dialog_id_.end();) {
if (all_dialogs.count(it->first)) {
++it;
} else {
std::vector<DialogId> to_remove;
for (auto it = stat_by_owner_dialog_id_.begin(); it != stat_by_owner_dialog_id_.end(); ++it) {
if (!all_dialogs.count(it->first)) {
for (int32 i = 0; i < MAX_FILE_TYPE; i++) {
other_stats[i].size += it->second[i].size;
other_stats[i].cnt += it->second[i].cnt;
}
other_flag = true;
it = stat_by_owner_dialog_id_.erase(it);
to_remove.push_back(it->first);
}
}
for (auto id : to_remove) {
stat_by_owner_dialog_id_.erase(id);
}
if (other_flag) {
DialogId other_dialog_id; // prevents MSVC warning C4709: comma operator within array index expression
stat_by_owner_dialog_id_[other_dialog_id] = other_stats;

View File

@ -14,7 +14,7 @@
#include "td/utils/tl_helpers.h"
#include <array>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -73,7 +73,7 @@ class FileStats {
using StatByType = std::array<FileTypeStat, MAX_FILE_TYPE>;
StatByType stat_by_type_;
std::unordered_map<DialogId, StatByType, DialogIdHash> stat_by_owner_dialog_id_;
FlatHashMap<DialogId, StatByType, DialogIdHash> stat_by_owner_dialog_id_;
vector<FullFileInfo> all_files_;
void add_impl(const FullFileInfo &info);

View File

@ -31,7 +31,7 @@
#include "td/utils/tl_parsers.h"
#include <functional>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
namespace td {
@ -184,7 +184,7 @@ void FileStatsWorker::get_stats(bool need_all_files, bool split_by_owner_dialog_
return promise.set_error(Global::request_aborted_error());
}
std::unordered_map<size_t, size_t> hash_to_pos;
FlatHashMap<size_t, size_t> hash_to_pos;
size_t pos = 0;
for (auto &full_info : full_infos) {
hash_to_pos[std::hash<std::string>()(full_info.path)] = pos;

View File

@ -37,7 +37,7 @@
#include <map>
#include <memory>
#include <set>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -107,8 +107,8 @@ class ConnectionCreator final : public NetQueryCallback {
static constexpr int32 MAX_PROXY_LAST_USED_SAVE_DELAY = 60;
std::map<int32, Proxy> proxies_;
std::unordered_map<int32, int32> proxy_last_used_date_;
std::unordered_map<int32, int32> proxy_last_used_saved_date_;
FlatHashMap<int32, int32> proxy_last_used_date_;
FlatHashMap<int32, int32> proxy_last_used_saved_date_;
int32 max_proxy_id_ = 0;
int32 active_proxy_id_ = 0;
ActorOwn<GetHostByNameActor> get_host_by_name_actor_;

View File

@ -32,7 +32,7 @@
#include <functional>
#include <map>
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <unordered_set>
#include <utility>
@ -174,7 +174,7 @@ class Session final
size_t ref_cnt;
std::vector<uint64> message_ids;
};
std::unordered_map<uint64, ContainerInfo> sent_containers_;
FlatHashMap<uint64, ContainerInfo> sent_containers_;
friend class GenAuthKeyActor;
struct HandshakeInfo {

View File

@ -25,7 +25,7 @@
#include "td/utils/tl_storers.h"
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -120,7 +120,7 @@ class BinlogKeyValue final : public KeyValueSyncInterface {
SeqNo set(string key, string value) final {
auto lock = rw_mutex_.lock_write().move_as_ok();
uint64 old_id = 0;
auto it_ok = map_.insert({key, {value, 0}});
auto it_ok = map_.emplace(key, std::make_pair(value, 0));
if (!it_ok.second) {
if (it_ok.first->second.first == value) {
return 0;
@ -192,9 +192,9 @@ class BinlogKeyValue final : public KeyValueSyncInterface {
binlog_->lazy_sync(std::move(promise));
}
std::unordered_map<string, string> prefix_get(Slice prefix) final {
FlatHashMap<string, string> prefix_get(Slice prefix) final {
auto lock = rw_mutex_.lock_write().move_as_ok();
std::unordered_map<string, string> res;
FlatHashMap<string, string> res;
for (const auto &kv : map_) {
if (begins_with(kv.first, prefix)) {
res[kv.first.substr(prefix.size())] = kv.second.first;
@ -203,9 +203,9 @@ class BinlogKeyValue final : public KeyValueSyncInterface {
return res;
}
std::unordered_map<string, string> get_all() final {
FlatHashMap<string, string> get_all() final {
auto lock = rw_mutex_.lock_write().move_as_ok();
std::unordered_map<string, string> res;
FlatHashMap<string, string> res;
for (const auto &kv : map_) {
res[kv.first] = kv.second.first;
}

View File

@ -11,7 +11,7 @@
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -34,9 +34,9 @@ class KeyValueSyncInterface {
virtual string get(const string &key) = 0;
virtual std::unordered_map<string, string> prefix_get(Slice prefix) = 0;
virtual FlatHashMap<string, string> prefix_get(Slice prefix) = 0;
virtual std::unordered_map<string, string> get_all() = 0;
virtual FlatHashMap<string, string> get_all() = 0;
virtual SeqNo erase(const string &key) = 0;

View File

@ -8,7 +8,7 @@
#include "td/utils/Slice.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -23,7 +23,7 @@ class SeqKeyValue {
~SeqKeyValue() = default;
SeqNo set(Slice key, Slice value) {
auto it_ok = map_.insert({key.str(), value.str()});
auto it_ok = map_.emplace(key.str(), value.str());
if (!it_ok.second) {
if (it_ok.first->second == value) {
return 0;
@ -62,12 +62,12 @@ class SeqKeyValue {
return map_.size();
}
std::unordered_map<string, string> get_all() const {
FlatHashMap<string, string> get_all() const {
return map_;
}
private:
std::unordered_map<string, string> map_;
FlatHashMap<string, string> map_;
SeqNo current_id_ = 0;
SeqNo next_seq_no() {
return ++current_id_;

View File

@ -60,7 +60,7 @@ void SqliteKeyValue::set(Slice key, Slice value) {
set_stmt_.reset();
}
void SqliteKeyValue::set_all(const std::unordered_map<string, string> &key_values) {
void SqliteKeyValue::set_all(const FlatHashMap<string, string> &key_values) {
begin_write_transaction().ensure();
for (auto &key_value : key_values) {
set(key_value.first, key_value.second);

View File

@ -13,7 +13,7 @@
#include "td/utils/SliceBuilder.h"
#include "td/utils/Status.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -41,7 +41,7 @@ class SqliteKeyValue {
void set(Slice key, Slice value);
void set_all(const std::unordered_map<string, string> &key_values);
void set_all(const FlatHashMap<string, string> &key_values);
string get(Slice key);
@ -61,8 +61,8 @@ class SqliteKeyValue {
void erase_by_prefix(Slice prefix);
std::unordered_map<string, string> get_all() {
std::unordered_map<string, string> res;
FlatHashMap<string, string> get_all() {
FlatHashMap<string, string> res;
get_by_prefix("", [&](Slice key, Slice value) {
res.emplace(key.str(), value.str());
return true;

View File

@ -24,7 +24,7 @@ class SqliteKeyValueAsync final : public SqliteKeyValueAsyncInterface {
void set(string key, string value, Promise<Unit> promise) final {
send_closure_later(impl_, &Impl::set, std::move(key), std::move(value), std::move(promise));
}
void set_all(std::unordered_map<string, string> key_values, Promise<Unit> promise) final {
void set_all(FlatHashMap<string, string> key_values, Promise<Unit> promise) final {
send_closure_later(impl_, &Impl::set_all, std::move(key_values), std::move(promise));
}
void erase(string key, Promise<Unit> promise) final {
@ -60,7 +60,7 @@ class SqliteKeyValueAsync final : public SqliteKeyValueAsyncInterface {
do_flush(false /*force*/);
}
void set_all(std::unordered_map<string, string> key_values, Promise<Unit> promise) {
void set_all(FlatHashMap<string, string> key_values, Promise<Unit> promise) {
do_flush(true /*force*/);
kv_->set_all(key_values);
promise.set_value(Unit());
@ -108,7 +108,7 @@ class SqliteKeyValueAsync final : public SqliteKeyValueAsyncInterface {
static constexpr double MAX_PENDING_QUERIES_DELAY = 0.01;
static constexpr size_t MAX_PENDING_QUERIES_COUNT = 100;
std::unordered_map<string, optional<string>> buffer_;
FlatHashMap<string, optional<string>> buffer_;
std::vector<Promise<Unit>> buffer_promises_;
size_t cnt_ = 0;

View File

@ -13,7 +13,7 @@
#include "td/utils/common.h"
#include <memory>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -23,7 +23,7 @@ class SqliteKeyValueAsyncInterface {
virtual void set(string key, string value, Promise<Unit> promise) = 0;
virtual void set_all(std::unordered_map<string, string> key_values, Promise<Unit> promise) = 0;
virtual void set_all(FlatHashMap<string, string> key_values, Promise<Unit> promise) = 0;
virtual void erase(string key, Promise<Unit> promise) = 0;

View File

@ -19,7 +19,7 @@
#include "td/utils/tl_storers.h"
#include <set>
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
namespace td {
@ -286,7 +286,7 @@ class TQueueImpl final : public TQueue {
int32 gc_at = 0;
};
std::unordered_map<QueueId, Queue> queues_;
FlatHashMap<QueueId, Queue> queues_;
std::set<std::pair<int32, QueueId>> queue_gc_at_;
unique_ptr<StorageCallback> callback_;

View File

@ -11,7 +11,7 @@
#include "td/utils/port/RwMutex.h"
#include "td/utils/Slice.h"
#include <unordered_map>
#include "td/utils/FlatHashMap.h"
#include <utility>
namespace td {
@ -52,7 +52,7 @@ class TsSeqKeyValue {
size_t size() const {
return kv_.size();
}
std::unordered_map<string, string> get_all() {
FlatHashMap<string, string> get_all() {
auto lock = rw_mutex_.lock_write().move_as_ok();
return kv_.get_all();
}

View File

@ -50,6 +50,7 @@
#if TD_HAVE_ABSL
#include <absl/container/flat_hash_map.h>
#include <absl/hash/hash.h>
#endif
struct CheckExitGuard {
@ -1174,7 +1175,7 @@ static void test_hash() {
TEST(Misc, Hasher) {
test_hash<td::TdHash>();
#if TD_HAVE_ABSL
test_hash<AbslHash>();
test_hash<td::AbslHash>();
#endif
}

View File

@ -457,7 +457,7 @@ TEST(DB, key_value_set_all) {
int queries_n = 100;
while (queries_n-- > 0) {
int cnt = td::Random::fast(0, 10);
std::unordered_map<td::string, td::string> key_values;
td::FlatHashMap<td::string, td::string> key_values;
for (int i = 0; i < cnt; i++) {
auto key = rand_elem(keys);
auto value = rand_elem(values);