Re: [PATCH] unit-tests: convert t/helper/test-oid-array.c to unit-tests
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Feb 27, 2024, 09:59 UTC
- Message-ID
- <CAP8UFD0yOXPyTvRCXxhoWXASW+HP230jVMCDzipg5PLAyVXJUA@mail.gmail.com>
- In-Reply-To
- <CZF8YROS9RVC.9H2EKYCF08VK@gmail.com>
On Mon, Feb 26, 2024 at 8:11 PM Ghanshyam Thakkar <shyamthakkar001@gmail.com> wrote:
> > On Mon Feb 26, 2024 at 8:41 PM IST, Christian Couder wrote:
Show 7 quoted lines
> > So I think it would be better to work on other things instead, like > > perhaps reviewing other people's work or working on other bug fixes or > > features. Anyway now that this is on the mailing list, I might as well > > review it as it could help with your application. But please consider > > working on other things. > > I understand and will work on other things.
Thanks!
Show 18 quoted lines
> > > In unit testing however, we do not > > > need to initialize the repo. We can set the length of the hexadecimal > > > strbuf according to the algorithm used directly. > > > > So is your patch doing that or not? It might be better to be explicit. > > Also if 'strbuf's are used, then is it really worth it to set their > > length in advance, instead of just letting them grow to the right > > length as we add hex to them? > > I thought of it like this: If we were to just let them grow, then we > would need separate logic for reusing that strbuf or use a different > one everytime since it always grows. By separating allocation > (hex_strbuf_init) and manipulation (fill_hex_strbuf), that same strbuf > can be reused for different hex values. > > But, none of the test currently need to reuse the same strbuf, so I > suppose it is better to just let it grow and even if the need arises we > can use strbuf_splice().
It's not a problem to use a new strbuf for each different hex value. Tests don't need a lot of performance as they are used mostly by developers, not by everyone using Git. Also if you want to reuse a strbuf, you can just use strbuf_reset() on it and then reuse it.