Thread (11 messages) flat view 11 messages, 2 authors, 2021-05-05

Re: [PATCH 2/5] streaming.c: remove enum/function/vtbl indirection

From: Jeff King <hidden>
Date: 2021-05-05 13:42:11

On Wed, May 05, 2021 at 02:33:29PM +0200, Ævar Arnfjörð Bjarmason wrote:
Remove the indirection of discovering a function pointer to use via an
enum and virtual table. This refactors code added in
46bf043807c (streaming: a new API to read from the object store,
2011-05-11).

We can instead simply return an "open_istream_fn" for use from the
"istream_source()" selector function directly. This allows us to get
rid of the "incore", "loose" and "pack_non_delta" enum
variables. We'll return the functions instead.

The "stream_error" variable in that enum can likewise go in favor of
returning NULL, which is what the open_istream() was doing when it got
that value anyway.

We can thus remove the entire enum, and the "open_istream_tbl" virtual
table that (indirectly) referenced it.
Yeah, I think this is simpler. The value of the vtable was that we might
have added more functions to it, but we haven't done so over the course
of the last 10 years. And I have trouble imagining for what purpose we
would. So it seems like unnecessary complexity.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help