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/json.hpp | |
parent | ff47134dc64ac2f0fa7bfee64313b2522709b9b9 (diff) | |
download | abaddon-portaudio-5a6f8cac09770d315fe4a3258fa6116e65750f24.tar.gz abaddon-portaudio-5a6f8cac09770d315fe4a3258fa6116e65750f24.zip |
first pass compile time optimization
Diffstat (limited to 'src/discord/json.hpp')
-rw-r--r-- | src/discord/json.hpp | 36 |
1 files changed, 18 insertions, 18 deletions
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()) |