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

Method insert_move_impl

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

Source from the content-addressed store, hash-verified

267}
268
269void vector_basic::insert_move_impl(fl::size index, void* element) {
270 if (index > mSize) index = mSize;
271 ensure_capacity(mSize + 1);
272 if (mSize >= mCapacity) return; // allocation failed
273
274 if (mOps) {
275 // Shift elements right, starting from the end
276 if (mSize > index) {
277 mOps->move_construct(element_ptr(mSize), element_ptr(mSize - 1));
278 for (fl::size i = mSize - 1; i > index; --i) {
279 mOps->destroy(element_ptr(i));
280 mOps->move_construct(element_ptr(i), element_ptr(i - 1));
281 }
282 mOps->destroy(element_ptr(index));
283 }
284 mOps->move_construct(element_ptr(index), element);
285 } else {
286 if (mSize > index) {
287 trivial_move_left(element_ptr(index + 1), element_ptr(index),
288 mSize - index);
289 }
290 fl::memcpy(element_ptr(index), element, mElementSize);
291 }
292 ++mSize;
293}
294
295// ======= RESIZE =======
296

Callers

nothing calls this directly

Calls 2

memcpyFunction · 0.50
destroyMethod · 0.45

Tested by

no test coverage detected