diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2014-06-29 12:56:35 -0500 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2014-06-29 12:56:35 -0500 |
commit | 426e724002780cf36e882e664c7e340c63a2942e (patch) | |
tree | 6b3056b2d0c8362751310f2e53f5d0fad3327365 /wikisort.c | |
parent | 111c49dac18a92523c0516da006049ab8a63df3d (diff) |
Don't bother merging when there are no pending elements
Diffstat (limited to 'wikisort.c')
-rw-r--r-- | wikisort.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -204,15 +204,18 @@ void wikisort(void *unsorted, size_t nmel, size_t width, cmpfun cmp) /* merge any previous pending as and bs */ nmel_pend_b -= offset; - if (nmel_pend_a) { + if (nmel_pend_a && nmel_pend_b) { merge_blocks(base, penda, nmel_pend_a, nmel_pend_b, width, cmp); } + + nmel_pend_a = bnmel; + nmel_pend_b = offset; } else { + nmel_pend_a = 0; + nmel_pend_b = 0; offset = 0; } - nmel_pend_a = bnmel; - nmel_pend_b = offset; penda = a.base - offset * width; a.base += bwidth; if (--a.blocks) { |