MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / resize

Method resize

app/src/DSP.h:268–288  ·  view source on GitHub ↗

* @brief Resizes the queue to a new capacity, preserving the most recent elements. */

Source from the content-addressed store, hash-verified

266 * @brief Resizes the queue to a new capacity, preserving the most recent elements.
267 */
268 void resize(std::size_t newCapacity)
269 {
270 if (newCapacity < 1)
271 newCapacity = 1;
272
273 if (newCapacity == m_capacity)
274 return;
275
276 const std::size_t newStorage = roundUpToPowerOfTwo(newCapacity);
277 std::shared_ptr<T[]> newData = makeStorage(newStorage);
278 std::size_t elementsToCopy = std::min(m_size, newCapacity);
279 for (std::size_t i = 0; i < elementsToCopy; ++i)
280 newData[i] = std::move((*this)[m_size - elementsToCopy + i]);
281
282 m_start = 0;
283 m_size = elementsToCopy;
284 m_capacity = newCapacity;
285 m_storageCapacity = newStorage;
286 m_storageMask = newStorage - 1;
287 m_data = std::move(newData);
288 }
289
290private:
291 // Plot-scale buffers are written per frame; smaller ones would waste page-locked quota

Callers 15

kissfftMethod · 0.45
kf_bfly_genericMethod · 0.45
kissfft_i32Method · 0.45
parseExtraFieldMethod · 0.45
setNTFSTimeFunction · 0.45
getCommentMethod · 0.45
getCurrentFileInfoMethod · 0.45
getCurrentFileNameMethod · 0.45
TESTFunction · 0.45
mdflibrary.cppFile · 0.45
CheckSampleBufferSizeMethod · 0.45
ParseCanMessageMethod · 0.45

Calls 1

roundUpToPowerOfTwoFunction · 0.70

Tested by 1

TESTFunction · 0.36