Re: [PATCH v2 02/11] reftable: consistently pass write opts as value
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 10, 2024, 21:11 UTC
- Message-ID
- <xmqqy18h2wys.fsf@gitster.g>
- In-Reply-To
- <e6f8fc09c282e620a331a737c30a190107c76996.1715336798.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 11 quoted lines
> We sometimes pass the refatble write options as value and sometimes as a > pointer. This is quite confusing and makes the reader wonder whether the > options get modified sometimes. > > In fact, `reftable_new_writer()` does cause the caller-provided options > to get updated when some values aren't set up. This is quite unexpected, > but didn't cause any harm until now. > > Refactor the code to consistently pass the options as a value so that > they are local to the subsystem they are being passed into so that we > can avoid weirdness like this.
Turning pass-by-reference to pass-by-value of a large structure is a rather huge hammer to ensure that the structure is not modified (qualifying the pointer with "const" is). Consistency is good, but I am not sure offhand if this is making things consistent in a good way.