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

Re: [PATCH 5/5] streaming.c: move {open,close,read} from vtable to "struct git_istream"

From
Jeff King <peff@peff.net>
Date
May 5, 2021, 13:55 UTC
Message-ID
<YJKj1bVEfWOWrvhs@coredump.intra.peff.net>
In-Reply-To
<patch-5.5-52606cd72ac-20210505T122816Z-avarab@gmail.com>
On Wed, May 05, 2021 at 02:33:32PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 13 quoted lines
> Move the definition of the structure around the open/close/read
> functions introduced in 46bf043807c (streaming: a new API to read from
> the object store, 2011-05-11) to instead populate "close" and "read"
> members in the "struct git_istream".
> 
> This gets us rid of an extra pointer deference, and I think makes more
> sense. The "close" and "read" functions are the primary interface to
> the stream itself.
> 
> Let's also populate a "open" callback in the same struct. That's now
> used by open_istream() after istream_source() decides what "open"
> function should be used. This isn't needed to get rid of the
> "stream_vtbl" variables, but makes sense for consistency.

Yeah, I think if we are going to get rid of the open vtable in an earlier patch, it makes sense to go all the way here and make things consistent.

If we had a bunch of these objects, having the layer of indirection to the vtable would save us some per-object memory. But we really only ever have one of these open at a time.

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 9 of 12 in “streaming.c: refactor for smaller + easier to understand code”
  1. 0/5 streaming.c: refactor for smaller + easier to understand codeÆvar Arnfjörð Bjarmason, May 5, 2021
  2. 1/5 streaming.c: avoid forward declarationsÆvar Arnfjörð Bjarmason, May 5, 2021
  3. 3/5 streaming.c: remove {open,close,read}_method_decl() macrosÆvar Arnfjörð Bjarmason, May 5, 2021
  4. Jeff KingMay 5, 2021
  5. 2/5 streaming.c: remove enum/function/vtbl indirectionÆvar Arnfjörð Bjarmason, May 5, 2021
  6. Jeff KingMay 5, 2021
  7. Junio C HamanoMay 6, 2021
  8. 5/5 streaming.c: move {open,close,read} from vtable to "struct git_istream"Ævar Arnfjörð Bjarmason, May 5, 2021
  9. Jeff KingMay 5, 2021
  10. 4/5 streaming.c: stop passing around "object_info *" to open()Ævar Arnfjörð Bjarmason, May 5, 2021
  11. Jeff KingMay 5, 2021
  12. Jeff KingMay 5, 2021

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.