As preparation for changing all accesses to the todo array to use a
helper function, do the .done check in the loop body.

Signed-off-by: Rasmus Villemoes <r...@rasmusvillemoes.dk>
---
 builtin/grep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index 6c1e90d43b..211ae54222 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -137,9 +137,11 @@ static void work_done(struct work_item *w)
        grep_lock();
        w->done = 1;
        old_done = todo_done;
-       for(; todo[todo_done].done && todo_done != todo_start;
+       for(; todo_done != todo_start;
            todo_done = (todo_done+1) % ARRAY_SIZE(todo)) {
                w = &todo[todo_done];
+               if (!w->done)
+                       break;
                if (w->out.len) {
                        const char *p = w->out.buf;
                        size_t len = w->out.len;
-- 
2.20.1

Reply via email to