mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-04 11:33:27 +03:00
dont use unordered collections (reduce memory a bit)
This commit is contained in:
@@ -234,19 +234,19 @@ std::optional<RoleData> DiscordClient::GetMemberHighestRole(Snowflake guild_id,
|
||||
});
|
||||
}
|
||||
|
||||
std::unordered_set<Snowflake> DiscordClient::GetUsersInGuild(Snowflake id) const {
|
||||
std::set<Snowflake> DiscordClient::GetUsersInGuild(Snowflake id) const {
|
||||
auto it = m_guild_to_users.find(id);
|
||||
if (it != m_guild_to_users.end())
|
||||
return it->second;
|
||||
|
||||
return std::unordered_set<Snowflake>();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unordered_set<Snowflake> DiscordClient::GetChannelsInGuild(Snowflake id) const {
|
||||
std::set<Snowflake> DiscordClient::GetChannelsInGuild(Snowflake id) const {
|
||||
auto it = m_guild_to_channels.find(id);
|
||||
if (it != m_guild_to_channels.end())
|
||||
return it->second;
|
||||
return std::unordered_set<Snowflake>();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool DiscordClient::HasGuildPermission(Snowflake user_id, Snowflake guild_id, Permission perm) const {
|
||||
@@ -954,12 +954,12 @@ PresenceStatus DiscordClient::GetUserStatus(Snowflake id) const {
|
||||
return PresenceStatus::Offline;
|
||||
}
|
||||
|
||||
std::unordered_map<Snowflake, RelationshipType> DiscordClient::GetRelationships() const {
|
||||
std::map<Snowflake, RelationshipType> DiscordClient::GetRelationships() const {
|
||||
return m_user_relationships;
|
||||
}
|
||||
|
||||
std::unordered_set<Snowflake> DiscordClient::GetRelationships(RelationshipType type) const {
|
||||
std::unordered_set<Snowflake> ret;
|
||||
std::set<Snowflake> DiscordClient::GetRelationships(RelationshipType type) const {
|
||||
std::set<Snowflake> ret;
|
||||
for (const auto &[id, rtype] : m_user_relationships)
|
||||
if (rtype == type)
|
||||
ret.insert(id);
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <mutex>
|
||||
#include <zlib.h>
|
||||
#include <glibmm.h>
|
||||
@@ -85,8 +84,8 @@ public:
|
||||
std::optional<BanData> GetBan(Snowflake guild_id, Snowflake user_id) const;
|
||||
Snowflake GetMemberHoistedRole(Snowflake guild_id, Snowflake user_id, bool with_color = false) const;
|
||||
std::optional<RoleData> GetMemberHighestRole(Snowflake guild_id, Snowflake user_id) const;
|
||||
std::unordered_set<Snowflake> GetUsersInGuild(Snowflake id) const;
|
||||
std::unordered_set<Snowflake> GetChannelsInGuild(Snowflake id) const;
|
||||
std::set<Snowflake> GetUsersInGuild(Snowflake id) const;
|
||||
std::set<Snowflake> GetChannelsInGuild(Snowflake id) const;
|
||||
|
||||
bool HasGuildPermission(Snowflake user_id, Snowflake guild_id, Permission perm) const;
|
||||
|
||||
@@ -184,8 +183,8 @@ public:
|
||||
|
||||
PresenceStatus GetUserStatus(Snowflake id) const;
|
||||
|
||||
std::unordered_map<Snowflake, RelationshipType> GetRelationships() const;
|
||||
std::unordered_set<Snowflake> GetRelationships(RelationshipType type) const;
|
||||
std::map<Snowflake, RelationshipType> GetRelationships() const;
|
||||
std::set<Snowflake> GetRelationships(RelationshipType type) const;
|
||||
std::optional<RelationshipType> GetRelationship(Snowflake id) const;
|
||||
|
||||
private:
|
||||
@@ -255,14 +254,14 @@ private:
|
||||
std::string m_token;
|
||||
|
||||
void AddUserToGuild(Snowflake user_id, Snowflake guild_id);
|
||||
std::unordered_map<Snowflake, std::unordered_set<Snowflake>> m_guild_to_users;
|
||||
std::map<Snowflake, std::set<Snowflake>> m_guild_to_users;
|
||||
|
||||
std::unordered_map<Snowflake, std::unordered_set<Snowflake>> m_guild_to_channels;
|
||||
std::unordered_map<Snowflake, GuildApplicationData> m_guild_join_requests;
|
||||
std::map<Snowflake, std::set<Snowflake>> m_guild_to_channels;
|
||||
std::map<Snowflake, GuildApplicationData> m_guild_join_requests;
|
||||
|
||||
std::unordered_map<Snowflake, PresenceStatus> m_user_to_status;
|
||||
std::map<Snowflake, PresenceStatus> m_user_to_status;
|
||||
|
||||
std::unordered_map<Snowflake, RelationshipType> m_user_relationships;
|
||||
std::map<Snowflake, RelationshipType> m_user_relationships;
|
||||
|
||||
UserData m_user_data;
|
||||
UserSettings m_user_settings;
|
||||
@@ -273,7 +272,7 @@ private:
|
||||
std::atomic<bool> m_client_connected = false;
|
||||
std::atomic<bool> m_ready_received = false;
|
||||
|
||||
std::unordered_map<std::string, GatewayEvent> m_event_map;
|
||||
std::map<std::string, GatewayEvent> m_event_map;
|
||||
void LoadEventMap();
|
||||
|
||||
std::thread m_heartbeat_thread;
|
||||
|
||||
Reference in New Issue
Block a user