Re: [PATCH] hex: use unsigned index for ring buffer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 25, 2016, 18:37 UTC
- Message-ID
- <xmqq4m40s2al.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20161025183347.u3cvowf2h6tabtuw@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 16 quoted lines
>> diff --git a/path.c b/path.c >> index fe3c4d96c6..9bfaeda207 100644 >> --- a/path.c >> +++ b/path.c >> @@ -24,7 +24,8 @@ static struct strbuf *get_pathname(void) >> STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT >> }; >> static int index; >> - struct strbuf *sb = &pathname_array[3 & ++index]; >> + struct strbuf *sb = &pathname_array[index]; >> + index = (index + 1) % ARRAY_SIZE(pathname_array); >> strbuf_reset(sb); >> return sb; > > This converts the pre-increment to a post-increment, but I don't think > it matters.
Yes, I think that using the ring buffer from the beginning, not from the second element from the beginning, is conceptually cleaner ;-).