Re: [PATCH v2 06/11] reftable/stack: reuse buffers when reloading stack
- From
Han-Wen Nienhuys <hanwenn@gmail.com>
- Date
- Dec 21, 2023, 10:58 UTC
- Message-ID
- <CAOw_e7bvud5M-1+kCi3gRuso3DqC19ujjKx079ORHKWiwC=Zzg@mail.gmail.com>
- In-Reply-To
- <ZXbRmwj1vZ2dA3s9@tanuki>
On Mon, Dec 11, 2023 at 10:08 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 12 quoted lines
> > This initially caught me by surprise, but on closer inspection I agree > > that this is OK, since stack_filename() calls strbuf_reset() before > > adjusting the buffer contents. > > > > (As a side-note, I do find the side-effect of stack_filename() to be a > > little surprising, but that's not the fault of this series and not worth > > changing here.) > > Agreed, I also found this to be a bit confusing at first. I'll amend the > commit message with "Note that we do not have to manually reset the > buffer because `stack_filename()` does this for us already." to help > future readers.
In C++ it is expected that assignment operators clear the destination before executing the assignment, so it depends on your expectations. If this is confusing, maybe another name is in order?
-- Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen