diff options
| author | Tyge Løvset <[email protected]> | 2022-11-15 18:50:49 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-11-15 18:50:49 +0100 |
| commit | 178f4f9048cc4b4db30d5ee694c3eb3158c34749 (patch) | |
| tree | 9d3a67ce3f5b6d8029cc0b7484e89c4874298da4 /include/stc/cbox.h | |
| parent | 688aa900792cf6629c2aa8c814dd590306ae05e0 (diff) | |
| download | STC-modified-178f4f9048cc4b4db30d5ee694c3eb3158c34749.tar.gz STC-modified-178f4f9048cc4b4db30d5ee694c3eb3158c34749.zip | |
More internal cleanup and fixes for cbox and carc.
Diffstat (limited to 'include/stc/cbox.h')
| -rw-r--r-- | include/stc/cbox.h | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 4c63d322..a5e01519 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -70,12 +70,6 @@ int main() { #ifndef _i_prefix #define _i_prefix cbox_ #endif -#if !(defined i_cmp || defined i_less || defined i_keyclass || defined i_valclass) - #define i_no_cmp -#endif -#if !(defined i_eq || defined i_hash || defined i_keyclass || defined i_valclass) - #define i_no_hash -#endif #include "template.h" typedef i_keyraw _cx_raw; @@ -152,40 +146,32 @@ STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self other) { *self = other; } -STC_INLINE int _cx_memb(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry) { - #if defined i_no_cmp - return memcmp(rx, ry, sizeof *rx); - #else - return i_cmp(rx, ry); - #endif -} - -STC_INLINE uint64_t _cx_memb(_raw_hash)(const _cx_raw* rx) { - #if defined i_no_hash - return c_default_hash(rx); - #else - return i_hash(rx); - #endif -} - -STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry) { - #if defined i_no_hash - return memcmp(rx, ry, sizeof *rx) == 0; - #else - return i_eq(rx, ry); - #endif -} - -STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* x) - { _cx_raw rx = i_keyto(x->get); return _cx_memb(_raw_hash)(&rx); } +#ifndef i_no_cmp +STC_INLINE int _cx_memb(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry) + { return i_cmp(rx, ry); } STC_INLINE int _cx_memb(_cmp)(const _cx_self* x, const _cx_self* y) { _cx_raw rx = i_keyto(x->get), ry = i_keyto(y->get); - return _cx_memb(_raw_cmp)(&rx, &ry); + return i_cmp(&rx, &ry); } +#endif + +#ifndef i_no_eq +STC_INLINE bool _cx_memb(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry) + { return i_eq(rx, ry); } STC_INLINE bool _cx_memb(_eq)(const _cx_self* x, const _cx_self* y) { _cx_raw rx = i_keyto(x->get), ry = i_keyto(y->get); - return _cx_memb(_raw_eq)(&rx, &ry); + return i_eq(&rx, &ry); } +#endif + +#ifndef i_no_hash +STC_INLINE uint64_t _cx_memb(_raw_hash)(const _cx_raw* rx) + { return i_hash(rx); } + +STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* x) + { _cx_raw rx = i_keyto(x->get); return i_hash(&rx); } +#endif + #include "template.h" |
