git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] wt-status.c: improve readability for wt_shortstatus_print
@ 2017-03-16 21:36 Stefan Beller
  2017-03-16 22:51 ` Jonathan Nieder
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Beller @ 2017-03-16 21:36 UTC (permalink / raw)
  To: gitster; +Cc: git, Stefan Beller

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 wt-status.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index d47012048f..a52d342695 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1785,34 +1785,24 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 
 static void wt_shortstatus_print(struct wt_status *s)
 {
-	int i;
+	struct string_list_item *it;
 
 	if (s->show_branch)
 		wt_shortstatus_print_tracking(s);
 
-	for (i = 0; i < s->change.nr; i++) {
-		struct wt_status_change_data *d;
-		struct string_list_item *it;
+	for_each_string_list_item(it, &s->change) {
+		struct wt_status_change_data *d = it->util;
 
-		it = &(s->change.items[i]);
-		d = it->util;
 		if (d->stagemask)
 			wt_shortstatus_unmerged(it, s);
 		else
 			wt_shortstatus_status(it, s);
 	}
-	for (i = 0; i < s->untracked.nr; i++) {
-		struct string_list_item *it;
-
-		it = &(s->untracked.items[i]);
+	for_each_string_list_item(it, &s->untracked)
 		wt_shortstatus_other(it, s, "??");
-	}
-	for (i = 0; i < s->ignored.nr; i++) {
-		struct string_list_item *it;
 
-		it = &(s->ignored.items[i]);
+	for_each_string_list_item(it, &s->ignored)
 		wt_shortstatus_other(it, s, "!!");
-	}
 }
 
 static void wt_porcelain_print(struct wt_status *s)
-- 
2.12.0.269.g1a05a5734c.dirty


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] wt-status.c: improve readability for wt_shortstatus_print
  2017-03-16 21:36 [PATCH] wt-status.c: improve readability for wt_shortstatus_print Stefan Beller
@ 2017-03-16 22:51 ` Jonathan Nieder
  2017-03-17  5:25   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Nieder @ 2017-03-16 22:51 UTC (permalink / raw)
  To: Stefan Beller; +Cc: gitster, git

Stefan Beller wrote:

> Subject: wt-status.c: improve readability for wt_shortstatus_print

Maybe:

	wt-status: simplify by using for_each_string_list_item

	Improve readability by using the for_each_string_list_item helper
	instead of manually iterating with an integer counter.

> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  wt-status.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)

I like the diffstat. :)

With or without a clarified commit message,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] wt-status.c: improve readability for wt_shortstatus_print
  2017-03-16 22:51 ` Jonathan Nieder
@ 2017-03-17  5:25   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2017-03-17  5:25 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Stefan Beller, git

Jonathan Nieder <jrnieder@gmail.com> writes:

> Stefan Beller wrote:
>
>> Subject: wt-status.c: improve readability for wt_shortstatus_print
>
> Maybe:
>
> 	wt-status: simplify by using for_each_string_list_item
>
> 	Improve readability by using the for_each_string_list_item helper
> 	instead of manually iterating with an integer counter.

Much better.  That matches what I read from the patch when I skimmed
it, but it did leave me wondering if I missed something else.

>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>>  wt-status.c | 20 +++++---------------
>>  1 file changed, 5 insertions(+), 15 deletions(-)
>
> I like the diffstat. :)

Me too ;-)

>
> With or without a clarified commit message,
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-17  5:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 21:36 [PATCH] wt-status.c: improve readability for wt_shortstatus_print Stefan Beller
2017-03-16 22:51 ` Jonathan Nieder
2017-03-17  5:25   ` Junio C Hamano

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).