diff --git a/app/src/main/cpp/skyline/common/utils.h b/app/src/main/cpp/skyline/common/utils.h index 1e9c62e7..d6bbe9d1 100644 --- a/app/src/main/cpp/skyline/common/utils.h +++ b/app/src/main/cpp/skyline/common/utils.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "base.h" namespace skyline::util { @@ -190,6 +191,16 @@ namespace skyline::util { return frozen::elsa{}(frozen::string(view.data(), view.size()), 0); } + /** + * @brief A fast hash for any trivial object that is designed to be utilized with hash-based containers + */ + template requires std::is_trivial_v + struct ObjectHash { + size_t operator()(const T &object) const noexcept { + return XXH64(&object, sizeof(object), 0); + } + }; + /** * @brief Selects the largest possible integer type for representing an object alongside providing the size of the object in terms of the underlying type */ @@ -263,8 +274,7 @@ namespace skyline::util { }; template - std::array MakeFilledArray(std::index_sequence, TArgs &&... args) - { + std::array MakeFilledArray(std::index_sequence, TArgs &&... args) { return {(void(Is), T(args...))...}; } @@ -272,4 +282,4 @@ namespace skyline::util { std::array MakeFilledArray(TArgs &&... args) { return MakeFilledArray(std::make_index_sequence(), std::forward(args)...); } -} \ No newline at end of file +}