diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-01-29 21:33:34 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-01-29 21:33:34 -0500 |
commit | 5a6f8cac09770d315fe4a3258fa6116e65750f24 (patch) | |
tree | d74c5407e4ba9b11700666ce1eed0c94984ae14a /src/discord | |
parent | ff47134dc64ac2f0fa7bfee64313b2522709b9b9 (diff) | |
download | abaddon-portaudio-5a6f8cac09770d315fe4a3258fa6116e65750f24.tar.gz abaddon-portaudio-5a6f8cac09770d315fe4a3258fa6116e65750f24.zip |
first pass compile time optimization
Diffstat (limited to 'src/discord')
-rw-r--r-- | src/discord/activity.hpp | 1 | ||||
-rw-r--r-- | src/discord/channel.cpp | 1 | ||||
-rw-r--r-- | src/discord/discord.cpp | 2 | ||||
-rw-r--r-- | src/discord/guild.cpp | 1 | ||||
-rw-r--r-- | src/discord/interactions.cpp | 1 | ||||
-rw-r--r-- | src/discord/json.hpp | 36 | ||||
-rw-r--r-- | src/discord/member.cpp | 1 | ||||
-rw-r--r-- | src/discord/permissions.hpp | 5 | ||||
-rw-r--r-- | src/discord/snowflake.cpp | 1 | ||||
-rw-r--r-- | src/discord/store.hpp | 1 | ||||
-rw-r--r-- | src/discord/user.cpp | 1 |
11 files changed, 21 insertions, 30 deletions
diff --git a/src/discord/activity.hpp b/src/discord/activity.hpp index 4382ac0..5b2c3ce 100644 --- a/src/discord/activity.hpp +++ b/src/discord/activity.hpp @@ -1,7 +1,6 @@ #pragma once #include <string> #include <optional> -#include "util.hpp" #include "json.hpp" #include "snowflake.hpp" diff --git a/src/discord/channel.cpp b/src/discord/channel.cpp index 1806201..4b1d909 100644 --- a/src/discord/channel.cpp +++ b/src/discord/channel.cpp @@ -1,4 +1,3 @@ -#include "abaddon.hpp" #include "channel.hpp" void from_json(const nlohmann::json &j, ThreadMetadataData &m) { diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index d7cee4c..c1b32d9 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -1,6 +1,4 @@ -#include "abaddon.hpp" #include "discord.hpp" -#include "util.hpp" #include <cinttypes> #include <utility> diff --git a/src/discord/guild.cpp b/src/discord/guild.cpp index bb99044..06c4acf 100644 --- a/src/discord/guild.cpp +++ b/src/discord/guild.cpp @@ -1,5 +1,4 @@ #include "guild.hpp" -#include "abaddon.hpp" void from_json(const nlohmann::json &j, GuildData &m) { JS_D("id", m.ID); diff --git a/src/discord/interactions.cpp b/src/discord/interactions.cpp index cc439fc..e23fc86 100644 --- a/src/discord/interactions.cpp +++ b/src/discord/interactions.cpp @@ -1,6 +1,5 @@ #include "interactions.hpp" #include "json.hpp" -#include "abaddon.hpp" void from_json(const nlohmann::json &j, MessageInteractionData &m) { JS_D("id", m.ID); diff --git a/src/discord/json.hpp b/src/discord/json.hpp index 3c6968d..b781e78 100644 --- a/src/discord/json.hpp +++ b/src/discord/json.hpp @@ -1,24 +1,24 @@ #pragma once #include <nlohmann/json.hpp> #include <optional> -#include "util.hpp" +#include "misc/is_optional.hpp" namespace detail { // more or less because idk what to name this stuff template<typename T> -inline void json_direct(const ::nlohmann::json &j, const char *key, T &val) { - if constexpr (::util::is_optional<T>::value) +inline void json_direct(const nlohmann::json &j, const char *key, T &val) { + if constexpr (is_optional<T>::value) val = j.at(key).get<typename T::value_type>(); else j.at(key).get_to(val); } template<typename T> -inline void json_optional(const ::nlohmann::json &j, const char *key, T &val) { - if constexpr (::util::is_optional<T>::value) { +inline void json_optional(const nlohmann::json &j, const char *key, T &val) { + if constexpr (is_optional<T>::value) { if (j.contains(key)) val = j.at(key).get<typename T::value_type>(); else - val = ::std::nullopt; + val = std::nullopt; } else { if (j.contains(key)) j.at(key).get_to(val); @@ -26,13 +26,13 @@ inline void json_optional(const ::nlohmann::json &j, const char *key, T &val) { } template<typename T> -inline void json_nullable(const ::nlohmann::json &j, const char *key, T &val) { - if constexpr (::util::is_optional<T>::value) { +inline void json_nullable(const nlohmann::json &j, const char *key, T &val) { + if constexpr (is_optional<T>::value) { const auto &at = j.at(key); if (!at.is_null()) val = at.get<typename T::value_type>(); else - val = ::std::nullopt; + val = std::nullopt; } else { const auto &at = j.at(key); if (!at.is_null()) @@ -41,16 +41,16 @@ inline void json_nullable(const ::nlohmann::json &j, const char *key, T &val) { } template<typename T> -inline void json_optional_nullable(const ::nlohmann::json &j, const char *key, T &val) { - if constexpr (::util::is_optional<T>::value) { +inline void json_optional_nullable(const nlohmann::json &j, const char *key, T &val) { + if constexpr (is_optional<T>::value) { if (j.contains(key)) { const auto &at = j.at(key); if (!at.is_null()) val = at.get<typename T::value_type>(); else - val = ::std::nullopt; + val = std::nullopt; } else { - val = ::std::nullopt; + val = std::nullopt; } } else { if (j.contains(key)) { @@ -62,14 +62,14 @@ inline void json_optional_nullable(const ::nlohmann::json &j, const char *key, T } template<typename T> -inline void json_update_optional_nullable(const ::nlohmann::json &j, const char *key, T &val) { - if constexpr (::util::is_optional<T>::value) { +inline void json_update_optional_nullable(const nlohmann::json &j, const char *key, T &val) { + if constexpr (is_optional<T>::value) { if (j.contains(key)) { const auto &at = j.at(key); if (!at.is_null()) val = at.get<typename T::value_type>(); else - val = ::std::nullopt; + val = std::nullopt; } } else { if (j.contains(key)) { @@ -83,8 +83,8 @@ inline void json_update_optional_nullable(const ::nlohmann::json &j, const char } template<typename T, typename U> -inline void json_update_optional_nullable_default(const ::nlohmann::json &j, const char *key, T &val, const U &fallback) { - if constexpr (::util::is_optional<T>::value) { +inline void json_update_optional_nullable_default(const nlohmann::json &j, const char *key, T &val, const U &fallback) { + if constexpr (is_optional<T>::value) { if (j.contains(key)) { const auto &at = j.at(key); if (at.is_null()) diff --git a/src/discord/member.cpp b/src/discord/member.cpp index e424491..2a8ae24 100644 --- a/src/discord/member.cpp +++ b/src/discord/member.cpp @@ -1,5 +1,4 @@ #include "member.hpp" -#include "abaddon.hpp" void from_json(const nlohmann::json &j, GuildMember &m) { JS_O("user", m.User); diff --git a/src/discord/permissions.hpp b/src/discord/permissions.hpp index 56ef742..d274dd9 100644 --- a/src/discord/permissions.hpp +++ b/src/discord/permissions.hpp @@ -1,8 +1,8 @@ #pragma once #include <cstdint> -#include "snowflake.hpp" #include "json.hpp" -#include "util.hpp" +#include "misc/bitwise.hpp" +#include "snowflake.hpp" constexpr static uint64_t PERMISSION_MAX_BIT = 36; enum class Permission : uint64_t { @@ -46,6 +46,7 @@ enum class Permission : uint64_t { ALL = 0x1FFFFFFFFFULL, }; + template<> struct Bitwise<Permission> { static const bool enable = true; diff --git a/src/discord/snowflake.cpp b/src/discord/snowflake.cpp index 856e2f7..15dacae 100644 --- a/src/discord/snowflake.cpp +++ b/src/discord/snowflake.cpp @@ -1,5 +1,4 @@ #include "snowflake.hpp" -#include "util.hpp" #include <chrono> #include <ctime> #include <iomanip> diff --git a/src/discord/store.hpp b/src/discord/store.hpp index f1e2f05..8e57e43 100644 --- a/src/discord/store.hpp +++ b/src/discord/store.hpp @@ -1,5 +1,4 @@ #pragma once -#include "util.hpp" #include "objects.hpp" #include <unordered_map> #include <unordered_set> diff --git a/src/discord/user.cpp b/src/discord/user.cpp index 0ab2af5..2ee7361 100644 --- a/src/discord/user.cpp +++ b/src/discord/user.cpp @@ -1,5 +1,4 @@ #include "user.hpp" -#include "abaddon.hpp" bool UserData::IsABot() const noexcept { return IsBot.has_value() && *IsBot; |