From c1765258b2d92409801ed6ecf79dbe5a764cb578 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Dec 2024 20:57:08 +0100 Subject: [PATCH] quickncasehash --- src/doomdef.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index c426e64e1..c8d2a28f7 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -522,6 +522,22 @@ extern boolean capslock; // i_system.c, replace getchar() once the keyboard has been appropriated INT32 I_GetKey(void); +/* http://www.cse.yorku.ca/~oz/hash.html */ +static inline +UINT32 quickncasehash (const char *p, size_t n) +{ + size_t i = 0; + UINT32 x = 5381; + + while (i < n && p[i]) + { + x = (x * 33) ^ tolower(p[i]); + i++; + } + + return x; +} + #ifndef min // Double-Check with WATTCP-32's cdefs.h #define min(x, y) (((x) < (y)) ? (x) : (y)) #endif