From cd688c11814dfb54571a32519befe2232682ecce Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 19 May 2021 13:42:03 +0200 Subject: Added HashStringDjb2() --- zencore/include/zencore/string.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index d7727ca08..684e27827 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -590,6 +590,21 @@ ParseInt(const std::string_view& Input) ////////////////////////////////////////////////////////////////////////// +constexpr uint32_t +HashStringDjb2(const std::string_view& InString) +{ + uint32_t HashValue = 5381; + + for (int c : InString) + { + HashValue = HashValue * 33 + c; + } + + return HashValue; +} + +////////////////////////////////////////////////////////////////////////// + void string_forcelink(); // internal } // namespace zen -- cgit v1.2.3