diff options
| author | tylov <[email protected]> | 2023-07-27 15:24:46 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-07-27 15:24:46 +0200 |
| commit | a64d171f0eb76c8f208ffc7d8501baa8222634d3 (patch) | |
| tree | cfb3df4aa28bfeedc4204c3609fa33319a11ad42 /include | |
| parent | c5e7742523c09520f1186458a574ef816f089821 (diff) | |
| download | STC-modified-a64d171f0eb76c8f208ffc7d8501baa8222634d3.tar.gz STC-modified-a64d171f0eb76c8f208ffc7d8501baa8222634d3.zip | |
An improvement in cvec/cdeq insert_uninit() impl.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cdeq.h | 2 | ||||
| -rw-r--r-- | include/stc/coroutine.h | 3 | ||||
| -rw-r--r-- | include/stc/cvec.h | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index cde2928c..b0575fe0 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -156,7 +156,7 @@ _cx_MEMB(_insert_uninit)(_cx_Self* self, const intptr_t idx, const intptr_t n) { const intptr_t len = _cx_MEMB(_size)(self); _cx_iter it = {._s=self}; if (len + n > self->capmask) - if (!_cx_MEMB(_reserve)(self, len + n)) + if (!_cx_MEMB(_reserve)(self, len*5/4 + n)) return it; for (intptr_t i = len - 1, j = i + n; i >= idx; --i, --j) *_cx_MEMB(_at_mut)(self, j) = *_cx_MEMB(_at)(self, i); diff --git a/include/stc/coroutine.h b/include/stc/coroutine.h index 42905744..9f55dddf 100644 --- a/include/stc/coroutine.h +++ b/include/stc/coroutine.h @@ -169,7 +169,8 @@ typedef struct cco_runtime { #define cco_task_blocking_1(task) cco_task_blocking_3(task, _rt, 16) #define cco_task_blocking_3(task, rt, STACKDEPTH) \ for (struct { int result, top; cco_task* stack[STACKDEPTH]; } rt = {.stack={cco_cast_task(task)}}; \ - (((rt.result = cco_task_resume(rt.stack[rt.top], (cco_runtime*)&rt)) & ~rt.stack[rt.top]->cco_expect) || --rt.top >= 0); ) + (((rt.result = cco_task_resume(rt.stack[rt.top], (cco_runtime*)&rt)) & \ + ~rt.stack[rt.top]->cco_expect) || --rt.top >= 0); ) /* * Semaphore diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 774f0582..e2b8fe97 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -326,7 +326,7 @@ _cx_MEMB(_push)(_cx_Self* self, i_key value) { 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) - if (!_cx_MEMB(_reserve)(self, self->_len*3/2 + n)) + if (!_cx_MEMB(_reserve)(self, self->_len*5/4 + n)) return _cx_MEMB(_end)(self); _cx_value* pos = self->data + idx; |
