diff options
| author | Tyge Løvset <[email protected]> | 2022-08-16 09:56:48 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-08-16 09:56:48 +0200 |
| commit | a06463c2f0747bc142a9d5b2bf455c64aaf39890 (patch) | |
| tree | 03825b177d4d5259f629957b751b000e1b224db1 /include | |
| parent | bf3c50da1a346b56b6846c0f7b9e7a222f602c2f (diff) | |
| download | STC-modified-a06463c2f0747bc142a9d5b2bf455c64aaf39890.tar.gz STC-modified-a06463c2f0747bc142a9d5b2bf455c64aaf39890.zip | |
Minor polishing.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cdeq.h | 27 | ||||
| -rw-r--r-- | include/stc/cvec.h | 9 |
2 files changed, 18 insertions, 18 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 0efbe064..a8c880f2 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -324,10 +324,10 @@ STC_DEF _cx_self _cx_memb(_clone)(_cx_self cx) { const size_t sz = cdeq_rep_(&cx)->size; _cx_self out = _cx_memb(_with_capacity)(sz); - if (cdeq_rep_(&out)->cap) { - cdeq_rep_(&out)->size = sz; - for (size_t i = 0; i < sz; ++i) - out.data[i] = i_keyclone(cx.data[i]); + struct cdeq_rep* r = cdeq_rep_(&out); + if (r->cap) { + for (size_t i = 0; i < sz; ++i) out.data[i] = i_keyclone(cx.data[i]); + r->size = sz; } return out; } @@ -403,28 +403,29 @@ _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2) { return c_make(_cx_iter){p2 == end ? NULL : p1, end - len}; } -#if !defined _i_no_emplace +#if !defined _i_no_clone STC_DEF _cx_iter -_cx_memb(_emplace_range)(_cx_self* self, _cx_value* pos, const _cx_raw* p1, const _cx_raw* p2) { +_cx_memb(_copy_range)(_cx_self* self, _cx_value* pos, + const _cx_value* p1, const _cx_value* p2) { _cx_iter it = _cx_memb(_insert_uninit)(self, pos, p2 - p1); if (it.ref) for (_cx_value* p = it.ref; p1 != p2; ++p1) - *p++ = i_keyfrom((*p1)); + *p++ = i_keyclone((*p1)); return it; } -#endif // !_i_no_emplace +#endif // !_i_no_clone -#if !defined _i_no_clone +#if !defined _i_no_emplace STC_DEF _cx_iter -_cx_memb(_copy_range)(_cx_self* self, _cx_value* pos, - const _cx_value* p1, const _cx_value* p2) { +_cx_memb(_emplace_range)(_cx_self* self, _cx_value* pos, + const _cx_raw* p1, const _cx_raw* p2) { _cx_iter it = _cx_memb(_insert_uninit)(self, pos, p2 - p1); if (it.ref) for (_cx_value* p = it.ref; p1 != p2; ++p1) - *p++ = i_keyclone((*p1)); + *p++ = i_keyfrom((*p1)); return it; } -#endif // !_i_no_clone +#endif // !_i_no_emplace #if !c_option(c_no_cmp) diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 1be7211d..6b120ff0 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -374,9 +374,8 @@ _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2) { STC_DEF _cx_self _cx_memb(_clone)(_cx_self cx) { const size_t len = cvec_rep_(&cx)->size; - _cx_self out = _cx_memb(_with_capacity)(len); - if (cvec_rep_(&out)->cap) - _cx_memb(_copy_range)(&out, out.data, cx.data, cx.data + len); + _cx_self out = _cx_memb(_init)(); + _cx_memb(_copy_range)(&out, out.data, cx.data, cx.data + len); return out; } @@ -385,8 +384,8 @@ _cx_memb(_copy_range)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2) { _cx_iter it = _cx_memb(_insert_uninit)(self, pos, p2 - p1); if (it.ref) - for (_cx_iter j = it; p1 != p2; ++p1) - *j.ref++ = i_keyclone((*p1)); + for (_cx_value* p = it.ref; p1 != p2; ++p1) + *p++ = i_keyclone((*p1)); return it; } #endif // !_i_no_clone |
