From 7c9343faae62800f6a4c39f7e127bcbde36cd584 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Mon, 30 Jun 2014 00:37:37 -0500 Subject: Small cleanup --- wikisort.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'wikisort.c') diff --git a/wikisort.c b/wikisort.c index 47e1def..7e9c196 100644 --- a/wikisort.c +++ b/wikisort.c @@ -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); -- cgit v1.2.3