From c37080d85af1a650dc4299b02bc9e87ac8ead965 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 12 May 2023 17:32:09 +0700 Subject: [PATCH] Use constinit instead of consteval --- routes/css.cpp | 6 +----- thirdparty/FastHash.h | 10 +--------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/routes/css.cpp b/routes/css.cpp index 31b9958..bb69822 100644 --- a/routes/css.cpp +++ b/routes/css.cpp @@ -134,11 +134,7 @@ static const constexpr char css[] = R"EOF( )EOF"; #define CSS_LEN sizeof(css) / sizeof(css[0]) - 1 -#ifdef __cpp_consteval -const uint64_t css_hash = FastHashConstEval(css, CSS_LEN, 0); -#else -const uint64_t css_hash = FastHash(css, CSS_LEN, 0); -#endif +constinit const uint64_t css_hash = FastHash(css, CSS_LEN, 0); void css_route(const httplib::Request& req, httplib::Response& res) { res.set_header("ETag", std::string(1, '"') + std::to_string(css_hash) + '"'); diff --git a/thirdparty/FastHash.h b/thirdparty/FastHash.h index f6b5815..8b97771 100644 --- a/thirdparty/FastHash.h +++ b/thirdparty/FastHash.h @@ -1,5 +1,5 @@ // https://github.com/KoneLinx/small_ECS/blob/master/FastHash.h -// but slightly modified to add FastHashConstEval and abandon ranges +// but slightly modified to abandon ranges // Copyright(C) 2021 Kobe Vrijsen // @@ -39,8 +39,6 @@ #pragma once -#include - // Compression function for Merkle-Damgard construction. // This function is generated using the framework provided. //#define mix(h) ({ @@ -76,9 +74,3 @@ constexpr uint64_t FastHash(const char* str, size_t size, uint64_t seed/*, uint6 return mix(h); } - -#ifdef __cpp_consteval -consteval uint64_t FastHashConstEval(const char* str, size_t size, uint64_t seed) { - return FastHash(str, size, seed); -} -#endif