diff options
| author | Tyge Løvset <[email protected]> | 2020-10-01 20:00:23 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-10-01 20:23:20 +0200 |
| commit | c79b9e561a2d4ca8eb36eb9afe45a07888c97277 (patch) | |
| tree | 2db54b25477e5d4fc9856c6430462c523a82c56c | |
| parent | d65f4e23190e34bc357c61824df45ea0f88b84a8 (diff) | |
| download | STC-modified-c79b9e561a2d4ca8eb36eb9afe45a07888c97277.tar.gz STC-modified-c79b9e561a2d4ca8eb36eb9afe45a07888c97277.zip | |
Minor refactoring.
| -rw-r--r-- | stc/cdefs.h | 6 | ||||
| -rw-r--r-- | stc/clist.h | 2 | ||||
| -rw-r--r-- | stc/cmap.h | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/stc/cdefs.h b/stc/cdefs.h index 1dcfeaef..909ba69e 100644 --- a/stc/cdefs.h +++ b/stc/cdefs.h @@ -96,13 +96,13 @@ enum {_c_max_buffer = 512}; #define c_push_items(self, ctype, ...) do { \
const ctype##_input_t __arr[] = __VA_ARGS__; \
- ctype##_push_n(self, __arr, sizeof(__arr)/sizeof(__arr[0])); \
+ ctype##_push_n(self, __arr, sizeof __arr/sizeof *__arr); \
} while (0)
#define c_del(ctype, ...) do { \
ctype##_t* __arr[] = {__VA_ARGS__}; \
- for (size_t i=0; i<sizeof(__arr)/sizeof(__arr[0]); ++i) \
- ctype##_del(__arr[i]); \
+ for (size_t __i=0; __i<sizeof __arr/sizeof *__arr; ++__i) \
+ ctype##_del(__arr[__i]); \
} while (0)
#endif
diff --git a/stc/clist.h b/stc/clist.h index 67ed0586..ef894cb3 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -92,7 +92,7 @@ ctype* __self = self; \
ctype##_iter_t __pos = pos; \
const ctype##_input_t __arr[] = __VA_ARGS__; \
- for (size_t __i=0; __i<sizeof(__arr)/sizeof(__arr[0]); ++__i) \
+ for (size_t __i=0; __i<sizeof __arr/sizeof *__arr; ++__i) \
__pos = ctype##_emplace_after(__self, __pos, __arr[__i]); \
} while (0)
@@ -64,9 +64,11 @@ int main(void) { ctype##_result_t __r = ctype##_insert_key_(self, key); \
if (__r.second) __r.first->second = val; \
} while (0)
+
#define c_insert_items(self, ctype, ...) do { \
const ctype##_input_t __arr[] = __VA_ARGS__; \
- for (size_t i=0;i<sizeof(__arr)/sizeof(__arr[0]); ++i) ctype##_insert(self, __arr[i]); \
+ for (size_t __i=0;__i<sizeof __arr/sizeof *__arr; ++__i) \
+ ctype##_insert(self, __arr[__i]); \
} while (0)
/* https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction */
|
