FastLED 3.10.8
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 387 of file cstdlib.cpp.hpp.

387 {
388 for (size_t i = 1; i < nmemb; ++i) {
389 // Save current element in temp buffer
390 char temp[256]; // Stack buffer for elements up to 256 bytes
391 char* elem_i = base + i * size;
392
393 if (size <= sizeof(temp)) {
394 memcpy(temp, elem_i, size);
395
396 size_t j = i;
397 while (j > 0 && compar(temp, base + (j - 1) * size) < 0) {
398 memcpy(base + j * size, base + (j - 1) * size, size);
399 --j;
400 }
401
402 memcpy(base + j * size, temp, size);
403 } else {
404 // For large elements, use swaps instead of shifts
405 size_t j = i;
406 while (j > 0 && compar(elem_i, base + (j - 1) * size) < 0) {
407 detail::qsort_swap(base + j * size, base + (j - 1) * size, size);
408 --j;
409 }
410 }
411 }
412}
void qsort_swap(char *a, char *b, size_t size) FL_NO_EXCEPT
FASTLED_FORCE_INLINE void * memcpy(void *dest, const void *src, size_t n) FL_NO_EXCEPT
Definition cstring.h:136

References FL_NO_EXCEPT, 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: