Use WaitFreeHashMap for pending_user_photos_.

This commit is contained in:
levlam 2022-11-20 22:48:01 +03:00
parent 3992c3695a
commit 3b46f78584
2 changed files with 4 additions and 5 deletions

View File

@ -5157,10 +5157,9 @@ void ContactsManager::apply_pending_user_photo(User *u, UserId user_id) {
return;
}
auto it = pending_user_photos_.find(user_id);
if (it != pending_user_photos_.end()) {
do_update_user_photo(u, user_id, std::move(it->second), "apply_pending_user_photo");
pending_user_photos_.erase(it);
if (pending_user_photos_.count(user_id) > 0) {
do_update_user_photo(u, user_id, std::move(pending_user_photos_[user_id]), "apply_pending_user_photo");
pending_user_photos_.erase(user_id);
update_user(u, user_id);
}
}

View File

@ -1764,7 +1764,7 @@ class ContactsManager final : public Actor {
WaitFreeHashMap<UserId, unique_ptr<UserFull>, UserIdHash> users_full_;
FlatHashMap<UserId, UserPhotos, UserIdHash> user_photos_;
mutable FlatHashSet<UserId, UserIdHash> unknown_users_;
FlatHashMap<UserId, tl_object_ptr<telegram_api::UserProfilePhoto>, UserIdHash> pending_user_photos_;
WaitFreeHashMap<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);