Cache reaction tag hash.
This commit is contained in:
parent
09122ba596
commit
096fc39bd1
@ -232,7 +232,10 @@ class UpdateSavedReactionTagQuery final : public Td::ResultHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ReactionManager::SavedReactionTag::SavedReactionTag(telegram_api::object_ptr<telegram_api::savedReactionTag> &&tag)
|
ReactionManager::SavedReactionTag::SavedReactionTag(telegram_api::object_ptr<telegram_api::savedReactionTag> &&tag)
|
||||||
: reaction_type_(tag->reaction_), title_(std::move(tag->title_)), count_(tag->count_) {
|
: reaction_type_(tag->reaction_)
|
||||||
|
, hash_(reaction_type_.get_hash())
|
||||||
|
, title_(std::move(tag->title_))
|
||||||
|
, count_(tag->count_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::savedMessagesTag> ReactionManager::SavedReactionTag::get_saved_messages_tag_object() const {
|
td_api::object_ptr<td_api::savedMessagesTag> ReactionManager::SavedReactionTag::get_saved_messages_tag_object() const {
|
||||||
@ -251,9 +254,7 @@ bool operator<(const ReactionManager::SavedReactionTag &lhs, const ReactionManag
|
|||||||
if (lhs.count_ != rhs.count_) {
|
if (lhs.count_ != rhs.count_) {
|
||||||
return lhs.count_ > rhs.count_;
|
return lhs.count_ > rhs.count_;
|
||||||
}
|
}
|
||||||
auto lhs_hash = lhs.reaction_type_.get_hash();
|
return lhs.hash_ > rhs.hash_;
|
||||||
auto rhs_hash = rhs.reaction_type_.get_hash();
|
|
||||||
return lhs_hash > rhs_hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder &operator<<(StringBuilder &string_builder, const ReactionManager::SavedReactionTag &saved_reaction_tag) {
|
StringBuilder &operator<<(StringBuilder &string_builder, const ReactionManager::SavedReactionTag &saved_reaction_tag) {
|
||||||
@ -305,6 +306,7 @@ void ReactionManager::SavedReactionTags::update_saved_messages_tags(const vector
|
|||||||
if (!is_found) {
|
if (!is_found) {
|
||||||
SavedReactionTag saved_reaction_tag;
|
SavedReactionTag saved_reaction_tag;
|
||||||
saved_reaction_tag.reaction_type_ = new_tag;
|
saved_reaction_tag.reaction_type_ = new_tag;
|
||||||
|
saved_reaction_tag.hash_ = new_tag.get_hash();
|
||||||
saved_reaction_tag.count_ = 1;
|
saved_reaction_tag.count_ = 1;
|
||||||
tags_.push_back(std::move(saved_reaction_tag));
|
tags_.push_back(std::move(saved_reaction_tag));
|
||||||
need_reload_title = true;
|
need_reload_title = true;
|
||||||
@ -320,7 +322,7 @@ void ReactionManager::SavedReactionTags::update_saved_messages_tags(const vector
|
|||||||
int64 ReactionManager::SavedReactionTags::calc_hash() const {
|
int64 ReactionManager::SavedReactionTags::calc_hash() const {
|
||||||
vector<uint64> numbers;
|
vector<uint64> numbers;
|
||||||
for (const auto &tag : tags_) {
|
for (const auto &tag : tags_) {
|
||||||
numbers.push_back(tag.reaction_type_.get_hash());
|
numbers.push_back(tag.hash_);
|
||||||
if (!tag.title_.empty()) {
|
if (!tag.title_.empty()) {
|
||||||
numbers.push_back(get_md5_string_hash(tag.title_));
|
numbers.push_back(get_md5_string_hash(tag.title_));
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ class ReactionManager final : public Actor {
|
|||||||
|
|
||||||
struct SavedReactionTag {
|
struct SavedReactionTag {
|
||||||
ReactionType reaction_type_;
|
ReactionType reaction_type_;
|
||||||
|
uint64 hash_ = 0;
|
||||||
string title_;
|
string title_;
|
||||||
int32 count_ = 0;
|
int32 count_ = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user