mirror-chatterino2/src/messages/Emote.cpp

28 lines
636 B
C++
Raw Normal View History

2018-08-02 14:23:27 +02:00
#include "Emote.hpp"
#include <unordered_map>
namespace chatterino {
bool operator==(const Emote &a, const Emote &b)
{
return std::tie(a.homePage, a.name, a.tooltip, a.images) ==
std::tie(b.homePage, b.name, b.tooltip, b.images);
}
bool operator!=(const Emote &a, const Emote &b)
{
return !(a == b);
}
2018-08-11 14:20:53 +02:00
EmotePtr cachedOrMakeEmotePtr(Emote &&emote, const EmoteMap &cache)
{
// reuse old shared_ptr if nothing changed
auto it = cache.find(emote.name);
if (it != cache.end() && *it->second == emote) return it->second;
2018-08-02 14:23:27 +02:00
2018-08-11 14:20:53 +02:00
return std::make_shared<Emote>(std::move(emote));
}
2018-08-02 14:23:27 +02:00
} // namespace chatterino