object-store: retire odb_load_loose_cache()
authorRené Scharfe <l.s.r@web.de>
Mon, 7 Jan 2019 17:29:16 +0000 (18:29 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Jan 2019 17:40:19 +0000 (09:40 -0800)
Inline odb_load_loose_cache() into its only remaining caller,
odb_loose_cache(). The latter offers a nicer interface for loading the
cache, as it doesn't require callers to deal with fanout directory
numbers directly.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-store.h
sha1-file.c
index 2fb6c0e4db132bcbd0957ddb8796d75ee402d974..e16aa38caebe69ae9bb3ace066f8103a60457407 100644 (file)
@@ -47,13 +47,6 @@ void add_to_alternates_file(const char *dir);
  */
 void add_to_alternates_memory(const char *dir);
 
-/*
- * Populate an odb's loose object cache for one particular subdirectory (i.e.,
- * the one that corresponds to the first byte of objects you're interested in,
- * from 0 to 255 inclusive).
- */
-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.
index c3c6e50704a8c7e1ff26676a6fe706175ead30f4..efcb2cbe747683297d2551da85e95b864120f692 100644 (file)
@@ -2154,12 +2154,6 @@ 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[subdir_nr];
-}
-
-void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
-{
        struct strbuf buf = STRBUF_INIT;
 
        if (subdir_nr < 0 ||
@@ -2167,7 +2161,7 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
                BUG("subdir_nr out of range");
 
        if (odb->loose_objects_subdir_seen[subdir_nr])
-               return;
+               return &odb->loose_objects_cache[subdir_nr];
 
        strbuf_addstr(&buf, odb->path);
        for_each_file_in_obj_subdir(subdir_nr, &buf,
@@ -2176,6 +2170,7 @@ void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
                                    &odb->loose_objects_cache[subdir_nr]);
        odb->loose_objects_subdir_seen[subdir_nr] = 1;
        strbuf_release(&buf);
+       return &odb->loose_objects_cache[subdir_nr];
 }
 
 void odb_clear_loose_cache(struct object_directory *odb)