git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Previous: Ghanshyam Thakkar
Message 5 of 5 in “unit-tests: convert t/helper/test-oid-array.c to unit-tests”
  1. unit-tests: convert t/helper/test-oid-array.c to unit-testsGhanshyam Thakkar, Feb 23, 2024
  2. Ghanshyam ThakkarFeb 23, 2024
  3. Christian CouderFeb 26, 2024
  4. Ghanshyam ThakkarFeb 26, 2024
  5. Christian CouderFeb 27, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.