summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cvec.h
diff options
context:
space:
mode:
authortylov <[email protected]>2023-08-11 09:04:15 +0200
committertylov <[email protected]>2023-08-11 09:04:15 +0200
commit3f9337aad678508f25ea83bcd4f5e5b95e69902c (patch)
tree117db0c571ea95f69946bb132eba7fab723794ea /include/stc/cvec.h
parent4ba846d378481cb74f68456a3ad4d7cd77d92522 (diff)
downloadSTC-modified-3f9337aad678508f25ea83bcd4f5e5b95e69902c.tar.gz
STC-modified-3f9337aad678508f25ea83bcd4f5e5b95e69902c.zip
Minor change to cvec_push()
Diffstat (limited to 'include/stc/cvec.h')
-rw-r--r--include/stc/cvec.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index e2b8fe97..dc16e94a 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -82,7 +82,6 @@ STC_API void _cx_MEMB(_drop)(_cx_Self* self);
STC_API void _cx_MEMB(_clear)(_cx_Self* self);
STC_API bool _cx_MEMB(_reserve)(_cx_Self* self, intptr_t cap);
STC_API bool _cx_MEMB(_resize)(_cx_Self* self, intptr_t size, i_key null);
-STC_API _cx_value* _cx_MEMB(_push)(_cx_Self* self, i_key value);
STC_API _cx_iter _cx_MEMB(_erase_n)(_cx_Self* self, intptr_t idx, intptr_t n);
STC_API _cx_iter _cx_MEMB(_insert_uninit)(_cx_Self* self, intptr_t idx, intptr_t n);
#if defined _i_has_eq || defined _i_has_cmp
@@ -94,6 +93,15 @@ STC_API _cx_iter _cx_MEMB(_binary_search_in)(_cx_iter it1, _cx_iter it2,
#endif
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 !defined i_no_emplace
STC_API _cx_iter
_cx_MEMB(_emplace_n)(_cx_Self* self, intptr_t idx, const _cx_raw raw[], intptr_t n);
@@ -313,16 +321,6 @@ _cx_MEMB(_resize)(_cx_Self* self, const intptr_t len, i_key null) {
return true;
}
-STC_DEF _cx_value*
-_cx_MEMB(_push)(_cx_Self* self, i_key value) {
- 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;
-}
-
STC_DEF _cx_iter
_cx_MEMB(_insert_uninit)(_cx_Self* self, const intptr_t idx, const intptr_t n) {
if (self->_len + n > self->_cap)