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
Jeff King <peff@peff.net>
Date
Jan 12, 2023, 16:53 UTC
Message-ID
<Y8A7Cb/w0VQk6ppV@coredump.intra.peff.net>
In-Reply-To
<230112.86v8lbzpj1.gmgdl@evledraar.gmail.com>
On Thu, Jan 12, 2023 at 05:22:04PM +0100, Ævar Arnfjörð Bjarmason wrote:
> We have members like "struct strbuf"'s "buf", which always needs to be
> init'd, but never "maybe by the user", so the pattern above would work
> there.

We've discussed in the past having a strbuf that points to an existing buffer, over which it takes ownership. Or a const string that we'd leave behind (but not free) if we needed to grow.

In those cases you'd want to pass in a buffer to the allocator. Of course in the case of a strbuf those initializers would probably just be totally separate from the regular slopbuf one, just because there's not much else in a strbuf to initialize. You don't gain much from trying to avoid repetition.

> Anyway, I agree that it's not worth pursuing this in this case.
> 
> But I think it's a neat pattern that we might find use for sooner than
> later for something else.

I remain unconvinced. ;) Mostly just that the lines saved versus the amount of magic and thought doesn't seem reasonable. But it's something we can keep in mind as new opportunities show up.

-Peff
Previous: Ævar Arnfjörð Bjarmason
Message 20 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.