git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Rasmus Villemoes <rv@rasmusvillemoes.dk>
To: git@vger.kernel.org
Cc: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Subject: [RFC PATCH 3/5] builtin/grep.c: add shorthand for &todo[todo_end] in add_work()
Date: Tue, 12 Feb 2019 23:26:52 +0100	[thread overview]
Message-ID: <20190212222654.7432-4-rv@rasmusvillemoes.dk> (raw)
In-Reply-To: <20190212222654.7432-1-rv@rasmusvillemoes.dk>

Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
---
 builtin/grep.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index 211ae54222..92b9e6198d 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -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);
-- 
2.20.1


  parent reply	other threads:[~2019-02-12 22:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 22:26 [RFC PATCH 0/5] builtin/grep.c: fix a tiny logic flaw Rasmus Villemoes
2019-02-12 22:26 ` [RFC PATCH 1/5] builtin/grep.c: change todo_* variables to unsigned Rasmus Villemoes
2019-02-12 22:26 ` [RFC PATCH 2/5] builtin/grep.c: refactor loop in work_done() slightly Rasmus Villemoes
2019-02-12 22:26 ` Rasmus Villemoes [this message]
2019-02-12 22:26 ` [RFC PATCH 4/5] builtin/grep.c: add todo_item helper Rasmus Villemoes
2019-02-12 22:26 ` [RFC PATCH 5/5] builtin/grep.c: fix fence-post error in add_work() Rasmus Villemoes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190212222654.7432-4-rv@rasmusvillemoes.dk \
    --to=rv@rasmusvillemoes.dk \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).