summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cspan.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-12 13:30:15 +0100
committerTyge Løvset <[email protected]>2023-03-12 13:30:15 +0100
commitc9be5f66a481bd040b36a25314f6589dd939daa5 (patch)
treed71cc01f17fabc526a72219c225b015b4130c8b3 /include/stc/cspan.h
parent1ac8bb4ff664baa838b44ed6bf62225766f000c5 (diff)
downloadSTC-modified-c9be5f66a481bd040b36a25314f6589dd939daa5.tar.gz
STC-modified-c9be5f66a481bd040b36a25314f6589dd939daa5.zip
Safer state machine in coroutine.h (internal).
Removed c_forwhile() macro. Redundant, use c_forfilter(). Removed find and eq in cspan (use general c_find_if() instead for search).
Diffstat (limited to 'include/stc/cspan.h')
-rw-r--r--include/stc/cspan.h21
1 files changed, 3 insertions, 18 deletions
diff --git a/include/stc/cspan.h b/include/stc/cspan.h
index 00313540..d5482200 100644
--- a/include/stc/cspan.h
+++ b/include/stc/cspan.h
@@ -48,9 +48,9 @@ int demo2() {
puts("");
c_forfilter (i, Intspan, span,
- , c_flt_skipwhile(i, *i.ref < 25)
- && (*i.ref & 1) == 0 // even only
- && c_flt_take(i, 2)) // break after 2
+ c_flt_skipwhile(i, *i.ref < 25) &&
+ (*i.ref & 1) == 0 && // even only
+ c_flt_take(i, 2)) // break after 2
printf(" %d", *i.ref);
puts("");
}
@@ -65,9 +65,6 @@ int demo2() {
using_cspan_3(Self, T, 1)
#define using_cspan_3(Self, T, RANK) \
- using_cspan_4(Self, T, RANK, c_default_eq)
-
-#define using_cspan_4(Self, T, RANK, i_eq) \
typedef T Self##_value; typedef T Self##_raw; \
typedef struct { \
Self##_value *data; \
@@ -99,18 +96,6 @@ int demo2() {
it->ref += _cspan_next##RANK(RANK, it->pos, it->_s->shape, it->_s->stride.d); \
if (it->pos[0] == it->_s->shape[0]) it->ref = NULL; \
} \
- STC_INLINE bool Self##_eq(const Self* x, const Self* y) { \
- if (memcmp(x->shape, y->shape, sizeof x->shape)) return false; \
- Self##_iter i = Self##_begin(x), j = Self##_begin(y); \
- for (; i.ref; Self##_next(&i), Self##_next(&j)) \
- if (!(i_eq(i.ref, j.ref))) return false; \
- return true; \
- } \
- STC_INLINE Self##_iter Self##_find(const Self* self, Self##_raw raw) { \
- Self##_iter i = Self##_begin(self); \
- for (; i.ref; Self##_next(&i)) if (i_eq(i.ref, &raw)) return i; \
- return i; \
- } \
struct stc_nostruct
#define using_cspan2(Self, T) using_cspan_3(Self, T, 1); using_cspan_3(Self##2, T, 2)