take out "asize" from vector/dequeue to picontainers.h->calcNewSize()
minAlloc and maxPoTAlloc now can be override from CMake by PIP_CONTAINERS_MIN_ALLOC and PIP_CONTAINERS_MAX_POT_ALLOC variables
This commit is contained in:
@@ -89,6 +89,26 @@ public:
|
||||
static const size_t ret = _PIContainerConstantsBase::calcStepAfterPoT(sizeof(T));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t calcNewSize(size_t old_size, size_t new_size) {
|
||||
if (new_size == 0) return 0;
|
||||
if (new_size < maxCountForPoT()) {
|
||||
if (old_size * 2 >= new_size && old_size < new_size) {
|
||||
return old_size * 2;
|
||||
}
|
||||
ssize_t t = minCountPoT();
|
||||
new_size -= 1;
|
||||
while (new_size >> t)
|
||||
++t;
|
||||
return (1 << t);
|
||||
} else {
|
||||
size_t ret = old_size;
|
||||
while (ret < new_size)
|
||||
ret += stepAfterPoT();
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user