From 59aa4ad21ac1d631fe4b739b34e0c6ee9d746455 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 2 May 2024 22:20:01 -0500 Subject: [PATCH] [cityhash] Cleanup --- deps/ox/deps/cityhash/include/cityhash/city.h | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/deps/ox/deps/cityhash/include/cityhash/city.h b/deps/ox/deps/cityhash/include/cityhash/city.h index d24101b3..c99bc7c0 100644 --- a/deps/ox/deps/cityhash/include/cityhash/city.h +++ b/deps/ox/deps/cityhash/include/cityhash/city.h @@ -100,27 +100,52 @@ typedef uint32_t uintptr_t; #error intptr_t, and uintptr_t undefined #endif -#endif - - using size_t = decltype(alignof(int)); - - -#if __has_include() -#include #endif - - namespace cityhash::detail { + +template +struct remove_reference { + using type = T; +}; + +template +struct remove_reference { + using type = T; +}; + +template +struct remove_reference { + using type = T; +}; + +template +using remove_reference_t = typename remove_reference::type; + +template +constexpr remove_reference_t &&move(T &&t) noexcept { + return static_cast&&>(t); +} + +template +using remove_reference_t = typename remove_reference::type; template struct pair { T1 first{}; T2 second{}; constexpr pair() noexcept = default; - constexpr pair(T1 a, T2 b) noexcept: first(std::move(a)), second(std::move(b)) {} + constexpr pair(T1 a, T2 b) noexcept: first(detail::move(a)), second(detail::move(b)) {} }; + +template +constexpr void swap(T &a, T &b) noexcept { + auto temp = detail::move(a); + a = detail::move(b); + b = detail::move(temp); +} + } namespace cityhash { @@ -129,13 +154,6 @@ using uint128 = cityhash::detail::pair; namespace detail { -template -constexpr void swap(T &a, T &b) noexcept { - auto temp = std::move(a); - a = std::move(b); - b = std::move(temp); -} - template [[nodiscard]] constexpr T byteSwap(T i) noexcept { @@ -290,7 +308,7 @@ constexpr uint32_t Hash32Len0to4(const char *s, size_t len) noexcept { uint32_t b = 0; uint32_t c = 9; for (size_t i = 0; i < len; i++) { - signed char v = static_cast(s[i]); + auto const v = static_cast(s[i]); b = b * detail::c1 + static_cast(v); c ^= b; }