Re: [PATCH 1/3] object-store: factor out odb_loose_cache()
- From
Jeff King <peff@peff.net>
- Date
- Jan 7, 2019, 08:27 UTC
- Message-ID
- <20190107082702.GB21362@sigill.intra.peff.net>
- In-Reply-To
- <b87e7e01-baa6-6fb2-7081-0042ecd3b6b7@web.de>
On Sun, Jan 06, 2019 at 05:45:30PM +0100, René Scharfe wrote:
> Add and use a function for loading the entries if a loose object > subdirectory for a given object ID. It frees callers from deriving the > fanout key; they can use the returned oid_array reference for lookups or > forward range scans.
Much nicer.
Show 15 quoted lines
> diff --git a/object-store.h b/object-store.h > index 60758efad8..7236c571c0 100644 > --- a/object-store.h > +++ b/object-store.h > @@ -54,6 +54,13 @@ void add_to_alternates_memory(const char *dir); > */ > void odb_load_loose_cache(struct object_directory *odb, int subdir_nr); > > +/* > + * Populate and return the loose object cache array corresponding to the > + * given object ID. > + */ > +struct oid_array *odb_loose_cache(struct object_directory *odb, > + const struct object_id *oid); > +
I think the ugly-interfaced odb_load_loose_cache() can become "static" now, as the only outside caller (from sha1-name.c) has gone away.
Show 9 quoted lines
> +struct oid_array *odb_loose_cache(struct object_directory *odb,
> + const struct object_id *oid)
> +{
> + int subdir_nr = oid->hash[0];
> + odb_load_loose_cache(odb, subdir_nr);
> + return &odb->loose_objects_cache;
> +}
> +
> void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)You'd need to re-order these definitions, of course (or alternatively, just fold the load function inline into odb_loose_cache()).
-Peff