summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortylo <[email protected]>2020-03-09 17:29:19 +0100
committertylo <[email protected]>2020-03-09 17:29:19 +0100
commitb3c5e7e311c6fa2ba37448cc6703d3c4add3637a (patch)
tree613df7e38d45241eecab3b88b6e7cc0b6a23ce13
parent7ef38a5f3dbf7fbda4137ca3f341e9b962362fab (diff)
downloadSTC-modified-b3c5e7e311c6fa2ba37448cc6703d3c4add3637a.tar.gz
STC-modified-b3c5e7e311c6fa2ba37448cc6703d3c4add3637a.zip
Minor
-rw-r--r--cdef.h25
-rw-r--r--cmap.h2
-rw-r--r--cstring.h4
3 files changed, 14 insertions, 17 deletions
diff --git a/cdef.h b/cdef.h
index 7a2e5521..3282f9ac 100644
--- a/cdef.h
+++ b/cdef.h
@@ -37,28 +37,25 @@
// #define foo_1(X) foo_2(X, 100)
// #define foo_2(X, Y) X + Y
-#define _cdef_max_alloca (1000)
-#define _cdef_swap(T, x, y) { T __t = x; x = y; y = __t; }
+#define _cdef_max_alloca (1000)
+#define _cdef_swap(T, x, y) { T __t = x; x = y; y = __t; }
-#define cdef_initRaw(x) (x)
-#define cdef_getRaw(x) (x)
-static inline void cdef_destroy(void* value) {}
+#define cdef_initRaw(x) (x)
+#define cdef_getRaw(x) (x)
+static inline void cdef_destroy(void* value) {}
-#define cforeach(it, ctag, con) \
- for (ctag##_iter_t it = ctag##_begin(con); it.item != ctag##_end(con).item; it = ctag##_next(it))
+#define cforeach(it, ctag, con) \
+ for (ctag##_iter_t it = ctag##_begin(con); it.item != ctag##_end(con).item; it = ctag##_next(it))
-static inline uint32_t
-cdef_murmurHash(const void *data, size_t len) // One-at-a-time 32bit
-{
+static inline uint32_t cdef_murmurHash(const void *data, size_t len) { // One-at-a-time 32bit
const unsigned char *key = (const unsigned char *) data;
- uint32_t h = 3323198485ul;
+ uint32_t h = 0xC613FC15; // ‭0x749E3E6989DF617‬; 64bit
while (len--) {
h ^= *key++;
- h *= 0x5bd1e995;
- h ^= h >> 15;
+ h *= 0x5bd1e995; // 0x5bd1e9955bd1e995; 64bit
+ h ^= h >> 15; // 47; 64bit
}
return h;
}
-
#endif \ No newline at end of file
diff --git a/cmap.h b/cmap.h
index fbd8c3ed..1bc8a615 100644
--- a/cmap.h
+++ b/cmap.h
@@ -68,7 +68,7 @@ typedef struct CMapEntry_##tag CMapEntry_##tag
declare_CMap_StringKey_3(tag, Value, cdef_destroy)
#define declare_CMap_StringKey_3(tag, Value, valueDestroy) \
- declare_CMap_10(tag, CString, Value, valueDestroy, const char*, cstring_make, cstring_getRaw, cstring_compare, cstring_hash, cstring_destroy)
+ declare_CMap_10(tag, CString, Value, valueDestroy, const char*, cstring_make, cstring_getRaw, cstring_compareRaw, cstring_hashRaw, cstring_destroy)
// CMap full:
diff --git a/cstring.h b/cstring.h
index b396f9e3..02dd3446 100644
--- a/cstring.h
+++ b/cstring.h
@@ -238,8 +238,8 @@ static inline char* cstring_splitNext(const char* delimiters) {
// CVector / CMap API functions:
#define cstring_getRaw(x) ((x).str)
-static inline uint32_t cstring_hash(const char** str, size_t sz_ignored) { return cdef_murmurHash(*str, strlen(*str)); }
-static inline int cstring_compare(CString* self, const char** str, size_t sz_ignored) { return strcmp(self->str, *str); }
+static inline uint32_t cstring_hashRaw(const char** str, size_t sz_ignored) { return cdef_murmurHash(*str, strlen(*str)); }
+static inline int cstring_compareRaw(CString* self, const char** str, size_t sz_ignored) { return strcmp(self->str, *str); }
#endif