crc32: moving to constexpr to prepare for the juliet serializer
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#pragma once
|
||||
#include <Core/Common/CoreUtils.h>
|
||||
#include <Core/Common/String.h>
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user