version 4.4.1

PIVector and PIDeque now growth to 64 MiB with PoT, then increments size by 64 MiB
in case of large containers it significantly save memory
This commit is contained in:
2024-11-21 00:10:14 +03:00
parent caa7880cc4
commit 9ab46e4afc
4 changed files with 37 additions and 19 deletions

View File

@@ -2461,14 +2461,22 @@ private:
inline size_t asize(size_t s) {
if (s == 0) return 0;
if (piv_rsize * 2 >= s && piv_rsize < s) {
return piv_rsize * 2;
if (s <= _PIContainerConstants<T>::maxCountForPoT()) {
if (piv_rsize * 2 >= s && piv_rsize < s) {
return piv_rsize * 2;
}
ssize_t t = _PIContainerConstants<T>::minCountPoT();
s -= 1;
while (s >> t)
++t;
return (1 << t);
} else {
size_t ret = piv_rsize;
while (ret < s)
ret += _PIContainerConstants<T>::stepAfterPoT();
return ret;
}
ssize_t t = _PIContainerConstants<T>::minCountPoT();
s -= 1;
while (s >> t)
++t;
return (1 << t);
return 0;
}
template<typename T1 = T, typename std::enable_if<!std::is_trivially_copyable<T1>::value, int>::type = 0>