• Home
  • Raw
  • Download

Lines Matching refs:stack_curr

322 static int CHECK_INVARIANT(TIM_SORT_RUN_T *stack, const int stack_curr) {  in CHECK_INVARIANT()  argument
325 if (stack_curr < 2) { in CHECK_INVARIANT()
329 if (stack_curr == 2) { in CHECK_INVARIANT()
330 const size_t A1 = stack[stack_curr - 2].length; in CHECK_INVARIANT()
331 const size_t B1 = stack[stack_curr - 1].length; in CHECK_INVARIANT()
340 A = stack[stack_curr - 3].length; in CHECK_INVARIANT()
341 B = stack[stack_curr - 2].length; in CHECK_INVARIANT()
342 C = stack[stack_curr - 1].length; in CHECK_INVARIANT()
371 static void TIM_SORT_MERGE(SORT_TYPE *dst, const TIM_SORT_RUN_T *stack, const int stack_curr, in TIM_SORT_MERGE() argument
373 const size_t A = stack[stack_curr - 2].length; in TIM_SORT_MERGE()
374 const size_t B = stack[stack_curr - 1].length; in TIM_SORT_MERGE()
375 const size_t curr = stack[stack_curr - 2].start; in TIM_SORT_MERGE()
423 static int TIM_SORT_COLLAPSE(SORT_TYPE *dst, TIM_SORT_RUN_T *stack, int stack_curr, in TIM_SORT_COLLAPSE() argument
430 if (stack_curr <= 1) { in TIM_SORT_COLLAPSE()
435 if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) { in TIM_SORT_COLLAPSE()
436 TIM_SORT_MERGE(dst, stack, stack_curr, store); in TIM_SORT_COLLAPSE()
438 stack_curr--; in TIM_SORT_COLLAPSE()
442 else if ((stack_curr == 2) && (stack[0].length <= stack[1].length)) { in TIM_SORT_COLLAPSE()
443 TIM_SORT_MERGE(dst, stack, stack_curr, store); in TIM_SORT_COLLAPSE()
445 stack_curr--; in TIM_SORT_COLLAPSE()
447 } else if (stack_curr == 2) { in TIM_SORT_COLLAPSE()
451 B = stack[stack_curr - 3].length; in TIM_SORT_COLLAPSE()
452 C = stack[stack_curr - 2].length; in TIM_SORT_COLLAPSE()
453 D = stack[stack_curr - 1].length; in TIM_SORT_COLLAPSE()
455 if (stack_curr >= 4) { in TIM_SORT_COLLAPSE()
456 A = stack[stack_curr - 4].length; in TIM_SORT_COLLAPSE()
472 TIM_SORT_MERGE(dst, stack, stack_curr - 1, store); in TIM_SORT_COLLAPSE()
473 stack[stack_curr - 3].length += stack[stack_curr - 2].length; in TIM_SORT_COLLAPSE()
474 stack[stack_curr - 2] = stack[stack_curr - 1]; in TIM_SORT_COLLAPSE()
475 stack_curr--; in TIM_SORT_COLLAPSE()
478 TIM_SORT_MERGE(dst, stack, stack_curr, store); in TIM_SORT_COLLAPSE()
479 stack[stack_curr - 2].length += stack[stack_curr - 1].length; in TIM_SORT_COLLAPSE()
480 stack_curr--; in TIM_SORT_COLLAPSE()
484 return stack_curr; in TIM_SORT_COLLAPSE()
492 size_t *stack_curr, in PUSH_NEXT() argument
506 run_stack[*stack_curr].start = *curr; in PUSH_NEXT()
507 run_stack[*stack_curr].length = len; in PUSH_NEXT()
508 (*stack_curr)++; in PUSH_NEXT()
513 while (*stack_curr > 1) { in PUSH_NEXT()
514 TIM_SORT_MERGE(dst, run_stack, *stack_curr, store); in PUSH_NEXT()
515 run_stack[*stack_curr - 2].length += run_stack[*stack_curr - 1].length; in PUSH_NEXT()
516 (*stack_curr)--; in PUSH_NEXT()
534 size_t stack_curr = 0; in TIM_SORT() local
554 if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { in TIM_SORT()
558 if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { in TIM_SORT()
562 if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { in TIM_SORT()
567 if (!CHECK_INVARIANT(run_stack, stack_curr)) { in TIM_SORT()
568 stack_curr = TIM_SORT_COLLAPSE(dst, run_stack, stack_curr, store, size); in TIM_SORT()
572 if (!PUSH_NEXT(dst, size, store, minrun, run_stack, &stack_curr, &curr)) { in TIM_SORT()