MCPcopy Create free account
hub / github.com/FastLED/FastLED / resize_value_impl

Method resize_value_impl

src/fl/stl/basic_vector.cpp.hpp:330–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330void vector_basic::resize_value_impl(fl::size n, const void* value) {
331 if (n == mSize) return;
332
333 if (n < mSize) {
334 if (mOps) {
335 for (fl::size i = n; i < mSize; ++i) {
336 mOps->destroy(element_ptr(i));
337 }
338 }
339 mSize = n;
340 return;
341 }
342
343 ensure_capacity(n);
344 if (mCapacity < n) return;
345
346 if (mOps) {
347 for (fl::size i = mSize; i < n; ++i) {
348 mOps->copy_construct(element_ptr(i), value);
349 }
350 } else {
351 for (fl::size i = mSize; i < n; ++i) {
352 fl::memcpy(element_ptr(i), value, mElementSize);
353 }
354 }
355 mSize = n;
356}
357
358// ======= SWAP =======
359

Callers 1

VectorNFunction · 0.80

Calls 2

memcpyFunction · 0.50
destroyMethod · 0.45

Tested by

no test coverage detected