MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / performAutoSqueeze

Method performAutoSqueeze

3rdparty/qcustomplot/qcustomplot.h:3422–3441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3420*/
3421template <class DataType>
3422void QCPDataContainer<DataType>::performAutoSqueeze()
3423{
3424 const int totalAlloc = mData.capacity();
3425 const int postAllocSize = totalAlloc-mData.size();
3426 const int usedSize = size();
3427 bool shrinkPostAllocation = false;
3428 bool shrinkPreAllocation = false;
3429 if (totalAlloc > 650000) // if allocation is larger, shrink earlier with respect to total used size
3430 {
3431 shrinkPostAllocation = postAllocSize > usedSize*1.5; // QVector grow strategy is 2^n for static data. Watch out not to oscillate!
3432 shrinkPreAllocation = mPreallocSize*10 > usedSize;
3433 } else if (totalAlloc > 1000) // below 10 MiB raw data be generous with preallocated memory, below 1k points don't even bother
3434 {
3435 shrinkPostAllocation = postAllocSize > usedSize*5;
3436 shrinkPreAllocation = mPreallocSize > usedSize*1.5; // preallocation can grow into postallocation, so can be smaller
3437 }
3438
3439 if (shrinkPreAllocation || shrinkPostAllocation)
3440 squeeze(shrinkPreAllocation, shrinkPostAllocation);
3441}
3442
3443
3444/* end of 'src/datacontainer.h' */

Callers

nothing calls this directly

Calls 3

sizeFunction · 0.85
capacityMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected