MCPcopy Create free account
hub / github.com/numpy/numpy / timsort_

Function timsort_

numpy/core/src/npysort/timsort.cpp:497–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495
496template <typename Tag>
497static int
498timsort_(void *start, npy_intp num)
499{
500 using type = typename Tag::type;
501 int ret;
502 npy_intp l, n, stack_ptr, minrun;
503 buffer_<Tag> buffer;
504 run stack[TIMSORT_STACK_SIZE];
505 buffer.pw = NULL;
506 buffer.size = 0;
507 stack_ptr = 0;
508 minrun = compute_min_run(num);
509
510 for (l = 0; l < num;) {
511 n = count_run_<Tag>((type *)start, l, num, minrun);
512 stack[stack_ptr].s = l;
513 stack[stack_ptr].l = n;
514 ++stack_ptr;
515 ret = try_collapse_<Tag>((type *)start, stack, &stack_ptr, &buffer);
516
517 if (NPY_UNLIKELY(ret < 0)) {
518 goto cleanup;
519 }
520
521 l += n;
522 }
523
524 ret = force_collapse_<Tag>((type *)start, stack, &stack_ptr, &buffer);
525
526 if (NPY_UNLIKELY(ret < 0)) {
527 goto cleanup;
528 }
529
530 ret = 0;
531cleanup:
532
533 free(buffer.pw);
534
535 return ret;
536}
537
538/* argsort */
539

Callers

nothing calls this directly

Calls 1

compute_min_runFunction · 0.85

Tested by

no test coverage detected