aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-05-19 13:42:03 +0200
committerStefan Boberg <[email protected]>2021-05-19 13:42:03 +0200
commitcd688c11814dfb54571a32519befe2232682ecce (patch)
tree1e82d70aa57194a4c1c06875f972ffdb3d973d03
parentMerge branch 'main' of https://github.com/EpicGames/zen into main (diff)
downloadzen-cd688c11814dfb54571a32519befe2232682ecce.tar.xz
zen-cd688c11814dfb54571a32519befe2232682ecce.zip
Added HashStringDjb2()
-rw-r--r--zencore/include/zencore/string.h15
1 files changed, 15 insertions, 0 deletions
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