From d7825270eece03f9f49bce7f1415284450fab065 Mon Sep 17 00:00:00 2001 From: Patedam Date: Sun, 6 Sep 2026 12:04:13 -0400 Subject: [PATCH] crc32: moving to constexpr to prepare for the juliet serializer --- Juliet/include/Core/Common/CRC32.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Juliet/include/Core/Common/CRC32.h b/Juliet/include/Core/Common/CRC32.h index d6be052..b462130 100644 --- a/Juliet/include/Core/Common/CRC32.h +++ b/Juliet/include/Core/Common/CRC32.h @@ -1,4 +1,6 @@ #pragma once +#include +#include // From https://web.mit.edu/freebsd/head/sys/libkern/crc32.c @@ -37,8 +39,9 @@ namespace details }; } -consteval uint32 crc32(const char* str, size_t length) +constexpr uint32 crc32(const char* str, size_t length) { + Assert(str && length > 0); const char* p = str; uint32_t crc = ~0U; while (length--) @@ -48,8 +51,12 @@ consteval uint32 crc32(const char* str, size_t length) return crc ^ ~0U; } +constexpr uint32 crc32(String str) +{ + return crc32(str.Str, str.Size); +} + consteval uint32 operator""_crc32(const char* str, size_t length) { return crc32(str, length); } -