| 3395 | are in reverse order. NLINES must be at least 2. */ |
| 3396 | |
| 3397 | static void |
| 3398 | mergelines (struct line *restrict t, size_t nlines, |
| 3399 | struct line const *restrict lo) |
| 3400 | { |
| 3401 | size_t nlo = nlines / 2; |
| 3402 | size_t nhi = nlines - nlo; |
| 3403 | struct line *hi = t - nlo; |
| 3404 | |
| 3405 | while (true) |
| 3406 | if (compare (lo - 1, hi - 1) <= 0) |
| 3407 | { |
| 3408 | *--t = *--lo; |
| 3409 | if (! --nlo) |
| 3410 | { |
| 3411 | /* HI must equal T now, and there is no need to copy from |
| 3412 | HI to T. */ |
| 3413 | return; |
| 3414 | } |
| 3415 | } |
| 3416 | else |
| 3417 | { |
| 3418 | *--t = *--hi; |
| 3419 | if (! --nhi) |
| 3420 | { |
| 3421 | do |
| 3422 | *--t = *--lo; |
| 3423 | while (--nlo); |
| 3424 | |
| 3425 | return; |
| 3426 | } |
| 3427 | } |
| 3428 | } |
| 3429 | |
| 3430 | /* Sort the array LINES with NLINES members, using TEMP for temporary space. |
| 3431 | Do this all within one thread. NLINES must be at least 2. |
no test coverage detected