From 405da5f84b072ea97b69359454899f45d92d24b6 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 22 May 2024 00:00:29 +0200 Subject: WIP LSP client This contains the start of an LSP client. Nothing (except starting the LSP server) works at the moment and the feature is disabled by default. --- src/dged/hash.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/dged/hash.c (limited to 'src/dged/hash.c') diff --git a/src/dged/hash.c b/src/dged/hash.c new file mode 100644 index 0000000..fce61af --- /dev/null +++ b/src/dged/hash.c @@ -0,0 +1,20 @@ +#include "hash.h" + +uint32_t hash_name(const char *s) { + unsigned long hash = 5381; + int c; + + while ((c = *s++)) + hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + + return hash; +} + +uint32_t hash_name_s8(struct s8 s) { + unsigned long hash = 5381; + + for (uint64_t i = 0; i < s.l; ++i) + hash = ((hash << 5) + hash) + s.s[i]; /* hash * 33 + c */ + + return hash; +} -- cgit v1.2.3