]> mj.ucw.cz Git - libucw.git/blobdiff - lib/sorter/govern.c
More bits of the array sorter: radix-sort implemented.
[libucw.git] / lib / sorter / govern.c
index 7b67110ba21318360976ac95263ee7b964c3d711..97ef04422b18d399b8b41e0e5691f95485ebf9b1 100644 (file)
@@ -158,7 +158,7 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b)
   do {
     ++pass;
     sorter_start_timer(ctx);
-    if (ins[0]->runs == 1 && ins[1]->runs == 1 && join)
+    if (ins[0]->runs <= 1 && ins[1]->runs <= 1 && join)
       {
        // This is guaranteed to produce a single run, so join if possible
        outs[0] = join;
@@ -226,7 +226,7 @@ sorter_multiway(struct sort_context *ctx, struct sort_bucket *b)
 
   if (part_cnt <= 1)
     {
-      sh_off_t size = sbuck_ins_or_join(clist_head(&parts), list_pos, join, join_size);
+      sh_off_t size = sbuck_ins_or_join(clist_head(&parts), list_pos, (part_cnt ? NULL : join), join_size);
       SORT_XTRACE(trace_level, "Sorted in memory (%s, %dMB/s)", stk_fsize(size), sorter_speed(ctx, size));
       return;
     }