@@ -93,18 +93,20 @@ static int skip_first_line;
static void add_work(struct grep_opt *opt, const struct grep_source *gs)
{
+ struct work_item *w;
+
grep_lock();
while ((todo_end+1) % ARRAY_SIZE(todo) == todo_done) {
pthread_cond_wait(&cond_write, &grep_mutex);
}
- todo[todo_end].source = *gs;
+ w = &todo[todo_end];
+ w->source = *gs;
if (opt->binary != GREP_BINARY_TEXT)
- grep_source_load_driver(&todo[todo_end].source,
- opt->repo->index);
- todo[todo_end].done = 0;
- strbuf_reset(&todo[todo_end].out);
+ grep_source_load_driver(&w->source, opt->repo->index);
+ w->done = 0;
+ strbuf_reset(&w->out);
todo_end = (todo_end + 1) % ARRAY_SIZE(todo);
pthread_cond_signal(&cond_add);
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk> --- builtin/grep.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)