From 1802558d41112e99d965000c97c45ebf7984d70c Mon Sep 17 00:00:00 2001 From: tylov Date: Sun, 13 Aug 2023 14:14:25 +0200 Subject: Fixed cqueue.h: cqueue_X_copy() was not defined inside a `c_no_clone` check. Reverted to 2X expansion for cvec to compete with gcc speed. --- include/stc/cvec.h | 14 +++++++------- include/stc/priv/cqueue_hdr.h | 11 +++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/stc/cvec.h b/include/stc/cvec.h index dc16e94a..12cd6875 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -94,13 +94,13 @@ STC_API _cx_iter _cx_MEMB(_binary_search_in)(_cx_iter it1, _cx_iter it2, STC_INLINE void _cx_MEMB(_value_drop)(_cx_value* val) { i_keydrop(val); } STC_INLINE _cx_value* _cx_MEMB(_push)(_cx_Self* self, i_key value) { - if (self->_len == self->_cap) - if (!_cx_MEMB(_reserve)(self, self->_len*3/2 + 4)) - return NULL; - _cx_value *v = self->data + self->_len++; - *v = value; - return v; -} + if (self->_len == self->_cap) + if (!_cx_MEMB(_reserve)(self, self->_len*2 + 4)) + return NULL; + _cx_value *v = self->data + self->_len++; + *v = value; + return v; + } #if !defined i_no_emplace STC_API _cx_iter diff --git a/include/stc/priv/cqueue_hdr.h b/include/stc/priv/cqueue_hdr.h index 1cad8684..06f3bd74 100644 --- a/include/stc/priv/cqueue_hdr.h +++ b/include/stc/priv/cqueue_hdr.h @@ -59,6 +59,11 @@ STC_API bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* othe STC_API _cx_Self _cx_MEMB(_clone)(_cx_Self cx); STC_INLINE i_key _cx_MEMB(_value_clone)(i_key val) { return i_keyclone(val); } +STC_INLINE void _cx_MEMB(_copy)(_cx_Self* self, const _cx_Self* other) { + if (self->data == other->data) return; + _cx_MEMB(_drop)(self); + *self = _cx_MEMB(_clone)(*other); + } #endif // !i_no_clone STC_INLINE intptr_t _cx_MEMB(_size)(const _cx_Self* self) { return _cdeq_toidx(self, self->end); } @@ -88,12 +93,6 @@ STC_INLINE _cx_value _cx_MEMB(_pull)(_cx_Self* self) { // move front out of queu return self->data[s]; } -STC_INLINE void _cx_MEMB(_copy)(_cx_Self* self, const _cx_Self* other) { - if (self->data == other->data) return; - _cx_MEMB(_drop)(self); - *self = _cx_MEMB(_clone)(*other); -} - STC_INLINE _cx_iter _cx_MEMB(_begin)(const _cx_Self* self) { return c_LITERAL(_cx_iter){ .ref=_cx_MEMB(_empty)(self) ? NULL : self->data + self->start, -- cgit v1.2.3