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

Re: [PATCH 06/10] reftable/generic: move generic iterator code into iterator interface

From
karthik nayak <karthik.188@gmail.com>
Date
Aug 15, 2024, 11:04 UTC
Message-ID
<CAOLa=ZQ=6y2jRNUt_0YyoEHTSgOc6y+ECEnLccXnntbqyU_J6Q@mail.gmail.com>
In-Reply-To
<xmqqh6bn1391.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> karthik nayak <karthik.188@gmail.com> writes:
>
>> Seems like the CI caught it too [1].
>>
>>> +	it->ops->close(it->iter_arg);
>>> +	it->ops = NULL;
>>> +	FREE_AND_NULL(it->iter_arg);
>>> +}
>>> +
>>
>> [snip]
>>
>> [1]: https://gitlab.com/gitlab-org/git/-/jobs/7563308943
>
> Looking at it, the suggestions the CI job makes look hit-and-miss.
>

Yup, this is kinda what I was expecting and why I also wanted it to be allowed to fail. So we have data points on what we should change to make it better.

Show 14 quoted lines
> For examle, this one
>
> -static int stack_compact_range_stats(struct reftable_stack *st,
> -				     size_t first, size_t last,
> +static int stack_compact_range_stats(struct reftable_stack *st, size_t first,
> +				     size_t last,
>  				     struct reftable_log_expiry_config *config,
>  				     unsigned int flags)
>
> is a degradation of readability.  "first" and "last" pretty
> much act as a pair and they read better sitting together next to
> each other.  The rewrite is reducing neither the total number of
> lines or the maximum column width.
>

Totally agreed, This is set by `ColumnLimit: 80` and I think most of the misses I see are because of this. This works with the `Penalties` we set at the bottom. We need to see what combination works best for us since our focus would be more on the readability front.

Show 27 quoted lines
> But this one
>
> -static void write_n_ref_tables(struct reftable_stack *st,
> -			       size_t n)
> +static void write_n_ref_tables(struct reftable_stack *st, size_t n)
>
> is certainly an improvement.
>
> This one
>
>  	struct reftable_record rec = {
>  		.type = BLOCK_TYPE_REF,
> -		.u = {
> -			.ref = *ref
> -		},
> +		.u = { .ref = *ref },
>  	};
>
> is hard to generalize but in this case it made a good suggestion.
>
> If we _expect_ that we will enumerate more members of .u, then the
> way originally written (plus trailing comma after the ".ref = *ref")
> would be easier to maintain.  But since .u is a union, we won't be
> choosing more than one member to initialize by definition, so what
> was suggested by the check-style linter is certainly much better.
>
> Thanks.

Yup these two do look much nicer indeed. There are weird bugs in clang-format however and I was able to fool it to accept

	struct reftable_record rec = {
		.type = BLOCK_TYPE_REF,
		.u = {
			.ref = *ref },
	};
But this could also be an issue with our config too.

I'll try playing around for an hour today to see if I can find some improvements we can make to the formatter config.

Thanks
Previous: Junio C HamanoNext: Patrick Steinhardt
Message 18 of 25 in “reftable: drop generic `reftable_table` interface”
  1. 00/10 reftable: drop generic `reftable_table` interfacePatrick Steinhardt, Aug 13, 2024
  2. 01/10 reftable/merged: expose functions to initialize iteratorsPatrick Steinhardt, Aug 13, 2024
  3. karthik nayakAug 13, 2024
  4. Patrick SteinhardtAug 14, 2024
  5. Justin ToblerAug 19, 2024
  6. Patrick SteinhardtAug 20, 2024
  7. 02/10 reftable/merged: rename `reftable_new_merged_table()`Patrick Steinhardt, Aug 13, 2024
  8. 03/10 reftable/merged: stop using generic tables in the merged tablePatrick Steinhardt, Aug 13, 2024
  9. karthik nayakAug 13, 2024
  10. Justin ToblerAug 19, 2024
  11. 04/10 reftable/stack: open-code reading refsPatrick Steinhardt, Aug 13, 2024
  12. 05/10 reftable/iter: drop double-checking logicPatrick Steinhardt, Aug 13, 2024
  13. Eric SunshineAug 13, 2024
  14. 06/10 reftable/generic: move generic iterator code into iterator interfacePatrick Steinhardt, Aug 13, 2024
  15. karthik nayakAug 13, 2024
  16. Patrick SteinhardtAug 14, 2024
  17. Junio C HamanoAug 14, 2024
  18. karthik nayakAug 15, 2024
  19. 07/10 reftable/dump: drop unused `compact_stack()`Patrick Steinhardt, Aug 13, 2024
  20. 08/10 reftable/dump: drop unused printing functionalityPatrick Steinhardt, Aug 13, 2024
  21. karthik nayakAug 13, 2024
  22. Patrick SteinhardtAug 14, 2024
  23. 09/10 reftable/dump: move code into "t/helper/test-reftable.c"Patrick Steinhardt, Aug 13, 2024
  24. 10/10 reftable/generic: drop interfacePatrick Steinhardt, Aug 13, 2024
  25. karthik nayakAug 13, 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.