From 664b5a6b227b2e8814a318b4de39820236e5efea Mon Sep 17 00:00:00 2001 From: Tylo Date: Mon, 22 Jun 2020 18:50:17 +0200 Subject: Restructure declare_CHash arguments (again) Removed forced inlining. (-> regular inline) --- examples/README.md | 6 +++--- examples/advanced.c | 2 +- examples/benchmark.c | 4 ++-- stc/cdefs.h | 7 ++++--- stc/chash.h | 12 ++++++------ 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/examples/README.md b/examples/README.md index c9952317..938bcb24 100644 --- a/examples/README.md +++ b/examples/README.md @@ -73,8 +73,8 @@ size_t personview_hash(const struct PersonView* pv, size_t ignore) { ``` With this in place, we can declare the map Person -> int: ``` -declare_CHash(ex, map, struct Person, int, c_emptyDestroy, personview_hash, personview_compare, - struct PersonView, person_destroy, person_getView, person_fromView); +declare_CHash(ex, MAP, struct Person, int, c_emptyDestroy, personview_hash, personview_compare, + person_destroy, struct PersonView, person_getView, person_fromView); ``` Note we use struct PersonView to put keys in the map, but keys are stored as struct Person with proper dynamically allocated CStrings to store name and surname. ``` @@ -94,5 +94,5 @@ int main() chash_ex_destroy(&m6); } ``` -CHash map uses personview_hash() for hash value calculations, and the personview_compare() for equality checks. The chash_ex_destroy() function will free CStrings name, surname and the value for each item in the map, in addition to the CMap hash table itself. +CHash map uses personview_hash() for hash value calculations, and the personview_compare() for equality checks. The chash_ex_destroy() function will free CStrings name, surname and the value for each item in the map, in addition to the CHash map table itself. diff --git a/examples/advanced.c b/examples/advanced.c index 37b67531..68d5b66a 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -65,7 +65,7 @@ size_t personview_hash(const struct PersonView* pv, size_t ignore) { With this in place, we can declare the map Person -> int: ```*/ declare_CHash(ex, MAP, struct Person, int, c_emptyDestroy, personview_hash, personview_compare, - struct PersonView, person_destroy, person_getView, person_fromView); + person_destroy, struct PersonView, person_getView, person_fromView); /*``` Note we use struct PersonView to put keys in the map, but keys are stored as struct Person with proper dynamically allocated CStrings to store name and surname. ```*/ diff --git a/examples/benchmark.c b/examples/benchmark.c index dd070ff4..b6e31a22 100644 --- a/examples/benchmark.c +++ b/examples/benchmark.c @@ -8,8 +8,8 @@ #ifdef __cplusplus #include -#include "../others/bytell_hash_map.hpp" -#include "../others/robin_hood.hpp" +#include "others/bytell_hash_map.hpp" +#include "others/robin_hood.hpp" #endif // Visual Studio: compile with -TP to force C++: cl -TP -EHsc -O2 benchmark.c diff --git a/stc/cdefs.h b/stc/cdefs.h index d8e3228d..ae707ec1 100644 --- a/stc/cdefs.h +++ b/stc/cdefs.h @@ -27,13 +27,14 @@ #include #include -#if defined(_MSC_VER) +#if 0 // defined(_MSC_VER) # define STC_INLINE __forceinline -#elif defined(__GNUC__) +#elif 0 // defined(__GNUC__) # define STC_INLINE inline __attribute((always_inline)) -#else +#else // don't force # define STC_INLINE inline #endif + #if defined(STC_HEADER) || defined(STC_IMPLEMENTATION) #define STC_API extern #else diff --git a/stc/chash.h b/stc/chash.h index 33f3e02c..8157b2c2 100644 --- a/stc/chash.h +++ b/stc/chash.h @@ -79,7 +79,7 @@ enum {chash_HASH = 0x7f, chash_USED = 0x80}; #define declare_CHash_7(tag, type, Key, Value, valueDestroy, keyHash, keyEquals) \ declare_CHash_11(tag, type, Key, Value, valueDestroy, keyHash, keyEquals, \ - Key, c_emptyDestroy, c_defaultGetRaw, c_defaultInitRaw) + c_emptyDestroy, Key, c_defaultGetRaw, c_defaultInitRaw) /* CHash: */ #define declare_CHash_string(...) \ @@ -93,7 +93,7 @@ enum {chash_HASH = 0x7f, chash_USED = 0x80}; #define declare_CHash_string_4(tag, type, Value, valueDestroy) \ declare_CHash_11(tag, type, CString, Value, valueDestroy, cstring_hashRaw, cstring_equalsRaw, \ - const char*, cstring_destroy, cstring_getRaw, cstring_make) + cstring_destroy, const char*, cstring_getRaw, cstring_make) #define _chash1_SET(x) #define _chash2_SET(x, y) x @@ -102,7 +102,7 @@ enum {chash_HASH = 0x7f, chash_USED = 0x80}; /* CHash full: */ #define declare_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \ - RawKey, keyDestroy, keyGetRaw, keyInitRaw) \ + keyDestroy, RawKey, keyGetRaw, keyInitRaw) \ typedef struct CHashEntry_##tag { \ Key key; \ _chash1_##type(Value value;) \ @@ -168,7 +168,7 @@ STC_API chash_##tag##_iter_t \ chash_##tag##_next(chash_##tag##_iter_t it); \ \ implement_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \ - RawKey, keyDestroy, keyGetRaw, keyInitRaw) \ + keyDestroy, RawKey, keyGetRaw, keyInitRaw) \ typedef Key CHashKey_##tag; \ typedef Value CHashValue_##tag @@ -176,7 +176,7 @@ typedef Value CHashValue_##tag #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) #define implement_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \ - RawKey, keyDestroy, keyGetRaw, keyInitRaw) \ + keyDestroy, RawKey, keyGetRaw, keyInitRaw) \ \ STC_API void \ chash_##tag##_destroy(CHash_##tag* self) { \ @@ -362,7 +362,7 @@ chash_##tag##_next(chash_##tag##_iter_t it) { \ #else #define implement_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \ - RawKey, keyDestroy, keyGetRaw, keyInitRaw) + keyDestroy, RawKey, keyGetRaw, keyInitRaw) #endif #endif -- cgit v1.2.3