FastLED 3.9.15
Loading...
Searching...
No Matches

◆ qsort_insertion_sort()

static void fl::qsort_insertion_sort ( char * base,
size_t nmemb,
size_t size,
qsort_compare_fn compar )
static

Definition at line 348 of file cstdlib.cpp.hpp.

348 {
349 for (size_t i = 1; i < nmemb; ++i) {
350 // Save current element in temp buffer
351 char temp[256]; // Stack buffer for elements up to 256 bytes
352 char* elem_i = base + i * size;
353
354 if (size <= sizeof(temp)) {
355 memcpy(temp, elem_i, size);
356
357 size_t j = i;
358 while (j > 0 && compar(temp, base + (j - 1) * size) < 0) {
359 memcpy(base + j * size, base + (j - 1) * size, size);
360 --j;
361 }
362
363 memcpy(base + j * size, temp, size);
364 } else {
365 // For large elements, use swaps instead of shifts
366 size_t j = i;
367 while (j > 0 && compar(elem_i, base + (j - 1) * size) < 0) {
368 detail::qsort_swap(base + j * size, base + (j - 1) * size, size);
369 --j;
370 }
371 }
372 }
373}
void qsort_swap(char *a, char *b, size_t size)
void * memcpy(void *dest, const void *src, size_t n) FL_NOEXCEPT

References memcpy(), and fl::detail::qsort_swap().

Referenced by fl::detail::qsort_impl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: