• Home
  • Raw
  • Download

Lines Matching refs:up

310 static IdxT partition (lua_State *L, IdxT lo, IdxT up) {  in partition()  argument
312 IdxT j = up - 1; /* will be decremented before first use */ in partition()
317 if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ in partition()
333 set2(L, up - 1, i); in partition()
346 static IdxT choosePivot (IdxT lo, IdxT up, unsigned int rnd) { in choosePivot() argument
347 IdxT r4 = (up - lo) / 4; /* range/4 */ in choosePivot()
349 lua_assert(lo + r4 <= p && p <= up - r4); in choosePivot()
357 static void auxsort (lua_State *L, IdxT lo, IdxT up, in auxsort() argument
359 while (lo < up) { /* loop for tail recursion */ in auxsort()
364 lua_geti(L, 1, up); in auxsort()
366 set2(L, lo, up); /* swap a[lo] - a[up] */ in auxsort()
369 if (up - lo == 1) /* only 2 elements? */ in auxsort()
371 if (up - lo < RANLIMIT || rnd == 0) /* small interval or no randomize? */ in auxsort()
372 p = (lo + up)/2; /* middle element is a good pivot */ in auxsort()
374 p = choosePivot(lo, up, rnd); in auxsort()
381 lua_geti(L, 1, up); in auxsort()
383 set2(L, p, up); /* swap a[up] - a[p] */ in auxsort()
387 if (up - lo == 2) /* only 3 elements? */ in auxsort()
391 lua_geti(L, 1, up - 1); /* push a[up - 1] */ in auxsort()
392 set2(L, p, up - 1); /* swap Pivot (a[p]) with a[up - 1] */ in auxsort()
393 p = partition(L, lo, up); in auxsort()
395 if (p - lo < up - p) { /* lower interval is smaller? */ in auxsort()
401 auxsort(L, p + 1, up, rnd); /* call recursively for upper interval */ in auxsort()
402 n = up - p; /* size of smaller interval */ in auxsort()
403 up = p - 1; /* tail call for [lo .. p - 1] (lower interval) */ in auxsort()
405 if ((up - lo) / 128 > n) /* partition too imbalanced? */ in auxsort()