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

Re: [PATCH 0/5] cleaning up read_object() family of functions

From
Derrick Stolee <derrickstolee@github.com>
Date
Jan 11, 2023, 20:17 UTC
Message-ID
<6c896cc8-2da9-a448-4ab6-2dc535fb0e2b@github.com>
In-Reply-To
<Y77/T8dktee3wOA5@coredump.intra.peff.net>
On 1/11/2023 1:26 PM, Jeff King wrote:
Show 13 quoted lines
> On Mon, Jan 09, 2023 at 10:09:32AM -0500, Derrick Stolee wrote:
> 
>> I did think that requiring callers to create their own object_info
>> structs (which takes at least four lines) would be too much, but
>> the number of new callers is so low that I think this is a fine place
>> to stop.
> 
> Yeah, that was my feeling. I do wonder if there's a way to make it
> easier for callers of oid_object_info_extended(), but I couldn't come up
> with anything that's nice enough to merit the complexity.
> 
> For example, here's an attempt to let the caller use designated
> initializers to set up the query struct:
> +	struct object_info oi = OBJECT_INFO(.typep = type,
> +					    .sizep = size,
> +					    .contentp = &data);
Your macro expansion creates this format:
	struct object_info oi = {
		.type = type,
		.sizep = size,
		.contentp = &data,
	};

And even this expansion looks a bit better than the inline updates:

> -	oi.typep = type;
> -	oi.sizep = size;
> -	oi.contentp = &data;

So maybe that's a preferred pattern that we could establish by replacing the existing callers. It's also such a minor point that I wouldn't say it's a high priority to do.

Thanks, -Stolee

Previous: Jeff KingNext: Jeff King
Message 15 of 20 in “cleaning up read_object() family of functions”
  1. 0/5 cleaning up read_object() family of functionsJeff King, Jan 7, 2023
  2. 1/5 object-file: inline calls to read_object()Jeff King, Jan 7, 2023
  3. Ævar Arnfjörð BjarmasonJan 12, 2023
  4. object-file: fix indent-with-spaceJeff King, Jan 12, 2023
  5. Ævar Arnfjörð BjarmasonJan 12, 2023
  6. Junio C HamanoJan 13, 2023
  7. 2/5 streaming: inline call to read_object_file_extended()Jeff King, Jan 7, 2023
  8. 3/5 read_object_file_extended(): drop lookup_replace optionJeff King, Jan 7, 2023
  9. 4/5 repo_read_object_file(): stop wrapping read_object_file_extended()Jeff King, Jan 7, 2023
  10. 5/5 packfile: inline custom read_object()Jeff King, Jan 7, 2023
  11. Ævar Arnfjörð BjarmasonJan 12, 2023
  12. Jeff KingJan 12, 2023
  13. Derrick StoleeJan 9, 2023
  14. Jeff KingJan 11, 2023
  15. Derrick StoleeJan 11, 2023
  16. Jeff KingJan 11, 2023
  17. Ævar Arnfjörð BjarmasonJan 12, 2023
  18. Jeff KingJan 12, 2023
  19. Ævar Arnfjörð BjarmasonJan 12, 2023
  20. Jeff KingJan 12, 2023

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.