From b49dd3163d699852450cf18c27f012c98a0fc2f8 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 26 Sep 2022 11:50:10 +0200 Subject: Another internal opt. --- include/stc/ccommon.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index a1eb812d..15cebe09 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -163,11 +163,11 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, ; it.ref != (C##_value*)_endref; C##_next(&it)) #ifndef c_FLT_STACK -#define c_FLT_STACK 16 +#define c_FLT_STACK 14 // 22, 30, .. #endif -#define c_flt_take(i, n) (++(i).stack[(i).top++] <= (n)) -#define c_flt_drop(i, n) (++(i).stack[(i).top++] > (n)) -#define c_flt_dropwhile(i, pred) ((i).stack[(i).top++] |= !(pred)) +#define c_flt_take(i, n) (++(i).s1[(i).s1top++] <= (n)) +#define c_flt_drop(i, n) (++(i).s1[(i).s1top++] > (n)) +#define c_flt_dropwhile(i, pred) ((i).s2[(i).s2top++] |= !(pred)) #define c_forfilter(...) c_MACRO_OVERLOAD(c_forfilter, __VA_ARGS__) #define c_forfilter4(it, C, cnt, filter) \ @@ -179,9 +179,10 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, #define c_foreach_s(i, C, start) \ for (struct {C##_iter it; C##_value *ref; \ - uint32_t index, top, stack[c_FLT_STACK];} \ + uint32_t s1[c_FLT_STACK+1], index; \ + uint8_t s2[c_FLT_STACK], s1top, s2top;} \ i = {.it=start, .ref=i.it.ref}; i.it.ref \ - ; C##_next(&i.it), i.ref = i.it.ref, ++i.index, i.top=0) + ; C##_next(&i.it), i.ref = i.it.ref, ++i.index, i.s1top=0, i.s2top=0) #define c_forwhile(i, C, cnt, cond) \ for (struct {C##_iter it; C##_value *ref; size_t index;} \ -- cgit v1.2.3