Skip to content

Commit 8be88db

Browse files
rscharfegitster
authored andcommitted
object-store: retire odb_load_loose_cache()
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4cea1ce commit 8be88db

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

object-store.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ void add_to_alternates_file(const char *dir);
4747
*/
4848
void add_to_alternates_memory(const char *dir);
4949

50-
/*
51-
* Populate an odb's loose object cache for one particular subdirectory (i.e.,
52-
* the one that corresponds to the first byte of objects you're interested in,
53-
* from 0 to 255 inclusive).
54-
*/
55-
void odb_load_loose_cache(struct object_directory *odb, int subdir_nr);
56-
5750
/*
5851
* Populate and return the loose object cache array corresponding to the
5952
* given object ID.

sha1-file.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,20 +2154,14 @@ struct oid_array *odb_loose_cache(struct object_directory *odb,
21542154
const struct object_id *oid)
21552155
{
21562156
int subdir_nr = oid->hash[0];
2157-
odb_load_loose_cache(odb, subdir_nr);
2158-
return &odb->loose_objects_cache[subdir_nr];
2159-
}
2160-
2161-
void odb_load_loose_cache(struct object_directory *odb, int subdir_nr)
2162-
{
21632157
struct strbuf buf = STRBUF_INIT;
21642158

21652159
if (subdir_nr < 0 ||
21662160
subdir_nr >= ARRAY_SIZE(odb->loose_objects_subdir_seen))
21672161
BUG("subdir_nr out of range");
21682162

21692163
if (odb->loose_objects_subdir_seen[subdir_nr])
2170-
return;
2164+
return &odb->loose_objects_cache[subdir_nr];
21712165

21722166
strbuf_addstr(&buf, odb->path);
21732167
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)
21762170
&odb->loose_objects_cache[subdir_nr]);
21772171
odb->loose_objects_subdir_seen[subdir_nr] = 1;
21782172
strbuf_release(&buf);
2173+
return &odb->loose_objects_cache[subdir_nr];
21792174
}
21802175

21812176
void odb_clear_loose_cache(struct object_directory *odb)

0 commit comments

Comments
 (0)