diff options
-rw-r--r-- | common.h | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -47,11 +47,8 @@ static void rotate(char *base, size_t size, size_t shift) static void distribute_buffer(char *base, size_t bufnmel, size_t sortnmel, size_t width, cmpfun cmp) { while (bufnmel) { - char *sorted = base + bufnmel * width; - - size_t insertpos = 0; - for (; insertpos < sortnmel && cmp(base, sorted + insertpos * width) > 0; insertpos++); - + char *sorted = base + bufnmel * width; + size_t insertpos = binary_search(base, sorted, sortnmel, width, cmp); if (insertpos > 0) { rotate(base, (bufnmel + insertpos) * width, bufnmel * width); } |