Re: [PATCH 06/23] refs: use `size_t` indexes when iterating over ref transaction updates
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- May 18, 2017, 04:55 UTC
- Message-ID
- <d9831944-47e0-e886-60ce-e3db151340dd@alum.mit.edu>
- In-Reply-To
- <CAGZ79kYspKC=NZDp8q46KO2pGBfsAfK8A=2PRDb2O1swOLf6MQ@mail.gmail.com>
On 05/17/2017 06:59 PM, Stefan Beller wrote:
Show 9 quoted lines
> On Wed, May 17, 2017 at 5:05 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote: > > Now this would want to have some selling words for it? > I do not see an advantage of this patch as-is. > > I mean technically we don't need a sign, so we use that extra bit > to be able to process transactions up to twice the size. But I doubt > that is the real reason. I'll read on, maybe a later patch will explain > why we do this here.
The reason to use `size_t` is not signedness but rather that it might be larger than `int` (e.g., 64 vs 32 bits), so you could theoretically get an integer overflow otherwise. It's unlikely here, because it would be hard to initiate an update of more than (2³¹-1) references in a single update, but it's good hygiene anyway.
I'll mention that in the commit message.
Michael