summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-11-21 17:43:36 +0100
committerTyge Løvset <[email protected]>2021-11-21 17:43:36 +0100
commit879f7a1c5637a5f67d430d3583fc7ba34b687234 (patch)
tree7793c829832f1b11cf87600307b0279f659d9a61
parent422272d1d87921b4524bdb276862687bf11b344d (diff)
downloadSTC-modified-879f7a1c5637a5f67d430d3583fc7ba34b687234.tar.gz
STC-modified-879f7a1c5637a5f67d430d3583fc7ba34b687234.zip
Made none mutable integers into const variables. Improved cmap_X_reserve() impl.
-rw-r--r--include/stc/cdeq.h59
-rw-r--r--include/stc/cmap.h41
-rw-r--r--include/stc/csmap.h8
-rw-r--r--include/stc/cvec.h48
4 files changed, 78 insertions, 78 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index a2314122..c9eb0627 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -46,7 +46,7 @@ STC_API _cx_self _cx_memb(_clone)(_cx_self cx);
STC_API void _cx_memb(_clear)(_cx_self* self);
STC_API void _cx_memb(_del)(_cx_self* self);
STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value);
-STC_API bool _cx_memb(_expand_right_half_)(_cx_self* self, size_t idx, size_t n);
+STC_API bool _cx_memb(_expand_right_half_)(_cx_self* self, const size_t idx, const size_t n);
#ifndef i_queue
STC_API _cx_iter _cx_memb(_find_in)(_cx_iter p1, _cx_iter p2, i_valraw raw);
@@ -87,7 +87,7 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs)
{ it.ref += offs; return it; }
STC_INLINE _cx_self
-_cx_memb(_with_capacity)(size_t n) {
+_cx_memb(_with_capacity)(const size_t n) {
_cx_self cx = _cx_memb(_init)();
_cx_memb(_expand_right_half_)(&cx, 0, n);
return cx;
@@ -112,7 +112,7 @@ STC_INLINE void _cx_memb(_pop_back)(_cx_self* self) {
i_valdel(p);
}
-STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, size_t idx) {
+STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, const size_t idx) {
assert(idx < cdeq_rep_(self)->size);
return self->data + idx;
}
@@ -122,17 +122,17 @@ STC_INLINE size_t _cx_memb(_index)(_cx_self cx, _cx_iter it) {
}
STC_INLINE bool
-_cx_memb(_reserve)(_cx_self* self, size_t n) {
- size_t sz = cdeq_rep_(self)->size;
+_cx_memb(_reserve)(_cx_self* self, const size_t n) {
+ const size_t sz = cdeq_rep_(self)->size;
return n <= sz || _cx_memb(_expand_right_half_)(self, sz, n - sz);
}
STC_INLINE _cx_iter
-_cx_memb(_insert)(_cx_self* self, size_t idx, i_val value) {
+_cx_memb(_insert)(_cx_self* self, const size_t idx, i_val value) {
return _cx_memb(_insert_range_p)(self, self->data + idx, &value, &value + 1, false);
}
STC_INLINE _cx_iter
-_cx_memb(_insert_n)(_cx_self* self, size_t idx, const _cx_value arr[], size_t n) {
+_cx_memb(_insert_n)(_cx_self* self, const size_t idx, const _cx_value arr[], const size_t n) {
return _cx_memb(_insert_range_p)(self, self->data + idx, arr, arr + n, false);
}
STC_INLINE _cx_iter
@@ -141,11 +141,11 @@ _cx_memb(_insert_at)(_cx_self* self, _cx_iter it, i_val value) {
}
STC_INLINE _cx_iter
-_cx_memb(_emplace)(_cx_self* self, size_t idx, i_valraw raw) {
+_cx_memb(_emplace)(_cx_self* self, const size_t idx, i_valraw raw) {
return _cx_memb(_emplace_range_p)(self, self->data + idx, &raw, &raw + 1);
}
STC_INLINE _cx_iter
-_cx_memb(_emplace_n)(_cx_self* self, size_t idx, const _cx_rawvalue arr[], size_t n) {
+_cx_memb(_emplace_n)(_cx_self* self, const size_t idx, const _cx_rawvalue arr[], const size_t n) {
return _cx_memb(_emplace_range_p)(self, self->data + idx, arr, arr + n);
}
STC_INLINE _cx_iter
@@ -158,7 +158,7 @@ _cx_memb(_emplace_range)(_cx_self* self, _cx_iter it, _cx_iter it1, _cx_iter it2
}
STC_INLINE _cx_iter
-_cx_memb(_erase_n)(_cx_self* self, size_t idx, size_t n) {
+_cx_memb(_erase_n)(_cx_self* self, const size_t idx, const size_t n) {
return _cx_memb(_erase_range_p)(self, self->data + idx, self->data + idx + n);
}
STC_INLINE _cx_iter
@@ -230,10 +230,10 @@ _cx_memb(_del)(_cx_self* self) {
}
STC_DEF size_t
-_cx_memb(_realloc_)(_cx_self* self, size_t n) {
+_cx_memb(_realloc_)(_cx_self* self, const size_t n) {
struct cdeq_rep* rep = cdeq_rep_(self);
- size_t sz = rep->size, cap = (size_t) (sz*1.7) + n + 7;
- size_t nfront = _cdeq_nfront(self);
+ const size_t sz = rep->size, cap = (size_t) (sz*1.7) + n + 7;
+ const size_t nfront = _cdeq_nfront(self);
rep = (struct cdeq_rep*) c_realloc(rep->cap ? rep : NULL,
offsetof(struct cdeq_rep, base) + cap*sizeof(i_val));
if (!rep) return 0;
@@ -244,19 +244,19 @@ _cx_memb(_realloc_)(_cx_self* self, size_t n) {
}
STC_DEF bool
-_cx_memb(_expand_right_half_)(_cx_self* self, size_t idx, size_t n) {
+_cx_memb(_expand_right_half_)(_cx_self* self, const size_t idx, const size_t n) {
struct cdeq_rep* rep = cdeq_rep_(self);
- size_t sz = rep->size, cap = rep->cap;
- size_t nfront = _cdeq_nfront(self), nback = cap - sz - nfront;
+ const size_t sz = rep->size, cap = rep->cap;
+ const size_t nfront = _cdeq_nfront(self), nback = cap - sz - nfront;
if (nback >= n || sz*1.3 + n > cap) {
if (!_cx_memb(_realloc_)(self, n)) return false;
memmove(self->data + idx + n, self->data + idx, (sz - idx)*sizeof(i_val));
} else {
#ifdef i_queue
- size_t pos = 0;
+ const size_t pos = 0;
#else
- size_t unused = cap - (sz + n);
- size_t pos = (nfront*2 < unused) ? nfront : unused/2;
+ const size_t unused = cap - (sz + n);
+ const size_t pos = (nfront*2 < unused) ? nfront : unused/2;
#endif
memmove(self->_base + pos, self->data, idx*sizeof(i_val));
memmove(self->data + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_val));
@@ -276,7 +276,7 @@ _cx_memb(_push_back)(_cx_self* self, i_val value) {
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self cx) {
- size_t sz = cdeq_rep_(&cx)->size;
+ const size_t sz = cdeq_rep_(&cx)->size;
_cx_self out = _cx_memb(_with_capacity)(sz);
cdeq_rep_(&out)->size = sz;
for (size_t i = 0; i < sz; ++i) out.data[i] = i_valfrom(i_valto(&cx.data[i]));
@@ -286,24 +286,25 @@ _cx_memb(_clone)(_cx_self cx) {
#ifndef i_queue
STC_DEF void
-_cx_memb(_expand_left_half_)(_cx_self* self, size_t idx, size_t n) {
+_cx_memb(_expand_left_half_)(_cx_self* self, const size_t idx, const size_t n) {
struct cdeq_rep* rep = cdeq_rep_(self);
- size_t sz = rep->size, cap = rep->cap;
- size_t nfront = _cdeq_nfront(self), nback = cap - sz - nfront;
+ size_t cap = rep->cap;
+ const size_t sz = rep->size;
+ const size_t nfront = _cdeq_nfront(self), nback = cap - sz - nfront;
if (nfront >= n) {
self->data = (_cx_value *) memmove(self->data - n, self->data, idx*sizeof(i_val));
} else {
if (sz*1.3 + n > cap) cap = _cx_memb(_realloc_)(self, n);
- size_t unused = cap - (sz + n);
- size_t pos = (nback*2 < unused) ? unused - nback : unused/2;
+ const size_t unused = cap - (sz + n);
+ const size_t pos = (nback*2 < unused) ? unused - nback : unused/2;
memmove(self->_base + pos + idx + n, self->data + idx, (sz - idx)*sizeof(i_val));
self->data = (_cx_value *) memmove(self->_base + pos, self->data, idx*sizeof(i_val));
}
}
STC_DEF _cx_value*
-_cx_memb(_insert_space_)(_cx_self* self, _cx_value* pos, size_t n) {
- size_t idx = pos - self->data;
+_cx_memb(_insert_space_)(_cx_self* self, const _cx_value* pos, const size_t n) {
+ const size_t idx = pos - self->data;
if (idx*2 < cdeq_rep_(self)->size) _cx_memb(_expand_left_half_)(self, idx, n);
else _cx_memb(_expand_right_half_)(self, idx, n);
if (n) cdeq_rep_(self)->size += n; /* do only if size > 0 */
@@ -323,7 +324,7 @@ _cx_memb(_push_front)(_cx_self* self, i_val value) {
STC_DEF _cx_iter
_cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos,
- const _cx_value* p1, const _cx_value* p2, bool clone) {
+ const _cx_value* p1, const _cx_value* p2, bool clone) {
pos = _cx_memb(_insert_space_)(self, pos, p2 - p1);
_cx_iter it = {pos};
if (clone) for (; p1 != p2; ++p1) *pos++ = i_valfrom(i_valto(p1));
@@ -341,7 +342,7 @@ _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_rawvalue* p
STC_DEF _cx_iter
_cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2) {
- size_t n = p2 - p1;
+ const size_t n = p2 - p1;
if (n > 0) {
_cx_value* p = p1, *end = self->data + cdeq_rep_(self)->size;
for (; p != p2; ++p) i_valdel(p);
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index b12b80c7..56ea32a3 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -87,11 +87,11 @@ typedef cx_SET_ONLY( i_keyraw )
i_valraw second; } )
_cx_rawvalue;
-STC_API _cx_self _cx_memb(_with_capacity)(size_t cap);
+STC_API _cx_self _cx_memb(_with_capacity)(const size_t cap);
STC_API _cx_self _cx_memb(_clone)(_cx_self map);
STC_API void _cx_memb(_del)(_cx_self* self);
STC_API void _cx_memb(_clear)(_cx_self* self);
-STC_API bool _cx_memb(_reserve)(_cx_self* self, size_t capacity);
+STC_API bool _cx_memb(_reserve)(_cx_self* self, const size_t capacity);
STC_API chash_bucket_t _cx_memb(_bucket_)(const _cx_self* self, const _cx_rawkey* rkeyptr);
STC_API _cx_result _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey);
STC_API void _cx_memb(_erase_entry)(_cx_self* self, _cx_value* val);
@@ -103,7 +103,7 @@ STC_INLINE bool _cx_memb(_empty)(_cx_self m) { return m.size == 0; }
STC_INLINE size_t _cx_memb(_size)(_cx_self m) { return m.size; }
STC_INLINE size_t _cx_memb(_bucket_count)(_cx_self map) { return map.bucket_count; }
STC_INLINE size_t _cx_memb(_capacity)(_cx_self map)
- { return (size_t)(map.bucket_count ? (map.bucket_count - 2)*map.max_load_factor : 0.f); }
+ { return map.bucket_count ? (map.bucket_count - 2)*map.max_load_factor : 0.f; }
STC_INLINE void _cx_memb(_swap)(_cx_self *map1, _cx_self *map2) {c_swap(_cx_self, *map1, *map2); }
STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey)
{ return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; }
@@ -228,7 +228,7 @@ _cx_memb(_erase_at)(_cx_self* self, _cx_iter it) {
#endif // CMAP_H_INCLUDED
STC_DEF _cx_self
-_cx_memb(_with_capacity)(size_t cap) {
+_cx_memb(_with_capacity)(const size_t cap) {
_cx_self h = _cmap_inits;
_cx_memb(_reserve)(&h, cap);
return h;
@@ -320,31 +320,29 @@ _cx_memb(_clone)(_cx_self m) {
}
STC_DEF bool
-_cx_memb(_reserve)(_cx_self* self, size_t _newcap) {
+_cx_memb(_reserve)(_cx_self* self, const size_t _newcap) {
if (_newcap < self->size) return true;
- size_t _oldcap = self->bucket_count;
- _newcap = (size_t) (2 + _newcap / self->max_load_factor) | 1;
+ const _cx_size _oldbuckets = self->bucket_count;
+ const _cx_size _nbuckets = ((_cx_size)(_newcap/self->max_load_factor) + 2) | 1;
_cx_self _tmp = {
- c_new_n(_cx_value, _newcap),
- (uint8_t *) c_calloc(_newcap + 1, sizeof(uint8_t)),
- self->size, (_cx_size) _newcap,
+ c_new_n(_cx_value, _nbuckets),
+ (uint8_t *) c_calloc(_nbuckets + 1, sizeof(uint8_t)),
+ self->size, (_cx_size) _nbuckets,
self->max_load_factor
};
- /* Rehash: */
- bool ret = true;
- if (!(_tmp.table && _tmp._hashx)) { ret = false; goto done; }
- _tmp._hashx[_newcap] = 0xff;
- c_swap(_cx_self, *self, _tmp);
- _cx_value* e = _tmp.table, *_slot = self->table;
- uint8_t* _hashx = self->_hashx;
- for (size_t i = 0; i < _oldcap; ++i, ++e)
- if (_tmp._hashx[i]) {
+ bool ret; /* Rehash: */
+ if ((ret = _tmp.table && _tmp._hashx)) {
+ _tmp._hashx[_nbuckets] = 0xff;
+ c_swap(_cx_self, *self, _tmp);
+ _cx_value* e = _tmp.table, *_slot = self->table;
+ uint8_t* _hashx = self->_hashx;
+ for (size_t i = 0; i < _oldbuckets; ++i, ++e) if (_tmp._hashx[i]) {
_cx_rawkey _raw = i_keyto(cx_keyref(e));
chash_bucket_t b = _cx_memb(_bucket_)(self, &_raw);
_slot[b.idx] = *e;
_hashx[b.idx] = (uint8_t) b.hx;
}
- done:
+ }
c_free(_tmp._hashx);
c_free((void *) _tmp.table);
return ret;
@@ -352,7 +350,8 @@ _cx_memb(_reserve)(_cx_self* self, size_t _newcap) {
STC_DEF void
_cx_memb(_erase_entry)(_cx_self* self, _cx_value* _val) {
- size_t i = chash_index_(*self, _val), j = i, k, _cap = self->bucket_count;
+ _cx_size i = chash_index_(*self, _val), j = i, k;
+ const _cx_size _cap = self->bucket_count;
_cx_value* _slot = self->table;
uint8_t* _hashx = self->_hashx;
_cx_memb(_value_del)(&_slot[i]);
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index 9d205c30..4e024c63 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -96,7 +96,7 @@ typedef cx_SET_ONLY( i_keyraw )
STC_API _cx_self _cx_memb(_init)(void);
STC_API _cx_self _cx_memb(_clone)(_cx_self tree);
STC_API void _cx_memb(_del)(_cx_self* self);
-STC_API bool _cx_memb(_reserve)(_cx_self* self, size_t cap);
+STC_API bool _cx_memb(_reserve)(_cx_self* self, const size_t cap);
STC_API _cx_value* _cx_memb(_find_it)(const _cx_self* self, i_keyraw rkey, _cx_iter* out);
STC_API _cx_iter _cx_memb(_lower_bound)(const _cx_self* self, i_keyraw rkey);
STC_API _cx_value* _cx_memb(_front)(const _cx_self* self);
@@ -120,9 +120,9 @@ STC_INLINE _cx_value* _cx_memb(_get_mut)(_cx_self* self, i_keyraw rkey)
{ _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it); }
STC_INLINE _cx_self
-_cx_memb(_with_capacity)(size_t size) {
+_cx_memb(_with_capacity)(const size_t cap) {
_cx_self tree = _cx_memb(_init)();
- _cx_memb(_reserve)(&tree, size);
+ _cx_memb(_reserve)(&tree, cap);
return tree;
}
@@ -238,7 +238,7 @@ _cx_memb(_back)(const _cx_self* self) {
}
STC_DEF bool
-_cx_memb(_reserve)(_cx_self* self, size_t cap) {
+_cx_memb(_reserve)(_cx_self* self, const size_t cap) {
struct csmap_rep* rep = _csmap_rep(self);
if (cap >= rep->size) {
_cx_size oldcap = rep->cap;
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 0c6bb817..5b58dca7 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -82,8 +82,8 @@ STC_API _cx_self _cx_memb(_init)(void);
STC_API _cx_self _cx_memb(_clone)(_cx_self cx);
STC_API void _cx_memb(_del)(_cx_self* self);
STC_API void _cx_memb(_clear)(_cx_self* self);
-STC_API bool _cx_memb(_reserve)(_cx_self* self, size_t cap);
-STC_API bool _cx_memb(_resize)(_cx_self* self, size_t size, i_val fill_val);
+STC_API bool _cx_memb(_reserve)(_cx_self* self, const size_t cap);
+STC_API bool _cx_memb(_resize)(_cx_self* self, const size_t size, i_val fill_val);
STC_API int _cx_memb(_value_compare)(const _cx_value* x, const _cx_value* y);
STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw raw);
STC_API _cx_iter _cx_memb(_bsearch_in)(_cx_iter it1, _cx_iter it2, i_valraw raw);
@@ -119,16 +119,16 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs)
STC_INLINE size_t _cx_memb(_index)(_cx_self cx, _cx_iter it) { return it.ref - cx.data; }
STC_INLINE _cx_self
-_cx_memb(_with_size)(size_t size, i_val null_val) {
+_cx_memb(_with_size)(const size_t size, i_val null_val) {
_cx_self cx = _cx_memb(_init)();
_cx_memb(_resize)(&cx, size, null_val);
return cx;
}
STC_INLINE _cx_self
-_cx_memb(_with_capacity)(size_t size) {
+_cx_memb(_with_capacity)(const size_t cap) {
_cx_self cx = _cx_memb(_init)();
- _cx_memb(_reserve)(&cx, size);
+ _cx_memb(_reserve)(&cx, cap);
return cx;
}
@@ -144,11 +144,11 @@ _cx_memb(_copy)(_cx_self *self, _cx_self other) {
}
STC_INLINE _cx_iter
-_cx_memb(_insert)(_cx_self* self, size_t idx, i_val value) {
+_cx_memb(_insert)(_cx_self* self, const size_t idx, i_val value) {
return _cx_memb(_insert_range_p)(self, self->data + idx, &value, &value + 1, false);
}
STC_INLINE _cx_iter
-_cx_memb(_insert_n)(_cx_self* self, size_t idx, const _cx_value arr[], size_t n) {
+_cx_memb(_insert_n)(_cx_self* self, const size_t idx, const _cx_value arr[], const size_t n) {
return _cx_memb(_insert_range_p)(self, self->data + idx, arr, arr + n, false);
}
STC_INLINE _cx_iter
@@ -157,11 +157,11 @@ _cx_memb(_insert_at)(_cx_self* self, _cx_iter it, i_val value) {
}
STC_INLINE _cx_iter
-_cx_memb(_emplace)(_cx_self* self, size_t idx, i_valraw raw) {
+_cx_memb(_emplace)(_cx_self* self, const size_t idx, i_valraw raw) {
return _cx_memb(_emplace_range_p)(self, self->data + idx, &raw, &raw + 1);
}
STC_INLINE _cx_iter
-_cx_memb(_emplace_n)(_cx_self* self, size_t idx, const _cx_rawvalue arr[], size_t n) {
+_cx_memb(_emplace_n)(_cx_self* self, const size_t idx, const _cx_rawvalue arr[], const size_t n) {
return _cx_memb(_emplace_range_p)(self, self->data + idx, arr, arr + n);
}
STC_INLINE _cx_iter
@@ -174,7 +174,7 @@ _cx_memb(_emplace_range)(_cx_self* self, _cx_iter it, _cx_iter it1, _cx_iter it2
}
STC_INLINE _cx_iter
-_cx_memb(_erase_n)(_cx_self* self, size_t idx, size_t n) {
+_cx_memb(_erase_n)(_cx_self* self, const size_t idx, const size_t n) {
return _cx_memb(_erase_range_p)(self, self->data + idx, self->data + idx + n);
}
STC_INLINE _cx_iter
@@ -187,7 +187,7 @@ _cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2) {
}
STC_INLINE const _cx_value*
-_cx_memb(_at)(const _cx_self* self, size_t idx) {
+_cx_memb(_at)(const _cx_self* self, const size_t idx) {
assert(idx < cvec_rep_(self)->size);
return self->data + idx;
}
@@ -253,9 +253,9 @@ _cx_memb(_del)(_cx_self* self) {
}
STC_DEF bool
-_cx_memb(_reserve)(_cx_self* self, size_t cap) {
+_cx_memb(_reserve)(_cx_self* self, const size_t cap) {
struct cvec_rep* rep = cvec_rep_(self);
- size_t len = rep->size;
+ const size_t len = rep->size;
if (cap >= len) {
rep = (struct cvec_rep*) c_realloc(rep->cap ? rep : NULL,
offsetof(struct cvec_rep, data) + cap*sizeof(i_val));
@@ -268,20 +268,20 @@ _cx_memb(_reserve)(_cx_self* self, size_t cap) {
}
STC_DEF bool
-_cx_memb(_resize)(_cx_self* self, size_t len, i_val fill) {
+_cx_memb(_resize)(_cx_self* self, const size_t len, i_val fill) {
if (len > _cx_memb(_capacity)(*self))
if (!_cx_memb(_reserve)(self, len)) return false;
- struct cvec_rep* rep = cvec_rep_(self);
- size_t i, n = rep->size;
- for (i = len; i < n; ++i) i_valdel(&self->data[i]);
- for (i = n; i < len; ++i) self->data[i] = fill;
+ struct cvec_rep *rep = cvec_rep_(self);
+ const size_t n = rep->size;
+ for (size_t i = len; i < n; ++i) i_valdel(&self->data[i]);
+ for (size_t i = n; i < len; ++i) self->data[i] = fill;
if (rep->cap) rep->size = len;
return true;
}
STC_DEF _cx_value*
_cx_memb(_push_back)(_cx_self* self, i_val value) {
- size_t len = cvec_rep_(self)->size;
+ const size_t len = cvec_rep_(self)->size;
if (len == _cx_memb(_capacity)(*self))
_cx_memb(_reserve)(self, (len*3 >> 1) + 4);
_cx_value *v = self->data + cvec_rep_(self)->size++;
@@ -290,15 +290,15 @@ _cx_memb(_push_back)(_cx_self* self, i_val value) {
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self cx) {
- size_t len = cvec_rep_(&cx)->size;
+ const size_t len = cvec_rep_(&cx)->size;
_cx_self out = _cx_memb(_with_capacity)(len);
_cx_memb(_insert_range_p)(&out, out.data, cx.data, cx.data + len, true);
return out;
}
STC_DEF _cx_value*
-_cx_memb(_insert_space_)(_cx_self* self, _cx_value* pos, size_t len) {
- size_t idx = pos - self->data, size = cvec_rep_(self)->size;
+_cx_memb(_insert_space_)(_cx_self* self, _cx_value* pos, const size_t len) {
+ const size_t idx = pos - self->data, size = cvec_rep_(self)->size;
if (len == 0) return pos;
if (size + len > _cx_memb(_capacity)(*self))
_cx_memb(_reserve)(self, (size*3 >> 1) + len),
@@ -319,8 +319,8 @@ _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos,
}
STC_DEF _cx_iter
-_cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_rawvalue* p1,
- const _cx_rawvalue* p2) {
+_cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos,
+ const _cx_rawvalue* p1, const _cx_rawvalue* p2) {
pos = _cx_memb(_insert_space_)(self, pos, p2 - p1);
_cx_iter it = {pos};
for (; p1 != p2; ++p1) *pos++ = i_valfrom(*p1);