summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wikisort.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/wikisort.c b/wikisort.c
index 2efa3ad..b2de063 100644
--- a/wikisort.c
+++ b/wikisort.c
@@ -96,18 +96,14 @@ static size_t roll(struct blockarray *a, struct blockarray *b,
size_t bwidth, size_t width, char **mina, cmpfun cmp)
{
size_t iters = 0;
- char *prevb;
-
- do {
+ while (b->blocks && cmp(b->base , *mina + bwidth - width) < 0) {
swap(a->base, b->base, bwidth);
if (*mina == a->base) *mina = b->base;
- prevb = a->base;
a->base += bwidth;
b->base += bwidth;
b->blocks--;
iters++;
- } while (b->blocks && cmp(prevb + bwidth - width, *mina) < 0);
-
+ }
return iters;
}