diff options
-rw-r--r-- | wikisort.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -192,7 +192,6 @@ void wikisort(void *unsorted, size_t nmel, size_t width, cmpfun cmp) char *mina = a.base, *penda; while (a.nmel) { size_t rolled_blocks = b.nmel ? roll(&a, &b, bwidth, width, &mina, cmp) : 0; - size_t offset; /* move mina block to immediately after rolled b blocks */ if (mina != a.base) swap(mina, a.base, bwidth); @@ -200,24 +199,22 @@ void wikisort(void *unsorted, size_t nmel, size_t width, cmpfun cmp) /* rotate mina into correct spot in the last rolled b */ nmel_pend_b += rolled_blocks * bnmel; if (nmel_pend_b) { - offset = nmel_pend_b - binary_search(a.base, a.base - nmel_pend_b * width, nmel_pend_b, width, cmp); + size_t offset = nmel_pend_b - binary_search(a.base, a.base - nmel_pend_b * width, nmel_pend_b, width, cmp); rotate(a.base - offset * width, bnmel + offset, width, offset); - /* merge any previous pending as and bs */ nmel_pend_b -= offset; if (nmel_pend_a && nmel_pend_b) { merge_blocks(buf.base, penda, nmel_pend_a, nmel_pend_b, width, cmp); } + penda = a.base - offset * width; nmel_pend_a = bnmel; nmel_pend_b = offset; } else { nmel_pend_a = 0; nmel_pend_b = 0; - offset = 0; } - penda = a.base - offset * width; a.base += bwidth; if (--a.nmel) { mina = find_min_block(a.base, a.nmel, bwidth, width, cmp); |