odb: move MRU list of packfiles into struct packfile_store

The object database tracks the list of packfiles in most-recently-used
order, which is mostly used to favor reading from packfiles that contain
most of the objects that we're currently accessing. With the
introduction of the `struct packfile_store` we have a better place to
host this list though.

Move the list accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-09-23 12:17:04 +02:00
committed by Junio C Hamano
parent 14aaf5c9d8
commit fe835b0ca0
5 changed files with 10 additions and 12 deletions

View File

@@ -1017,10 +1017,10 @@ static void prepare_packed_git_mru(struct repository *r)
{
struct packed_git *p;
INIT_LIST_HEAD(&r->objects->packed_git_mru);
INIT_LIST_HEAD(&r->objects->packfiles->mru);
for (p = r->objects->packfiles->packs; p; p = p->next)
list_add_tail(&p->mru, &r->objects->packed_git_mru);
list_add_tail(&p->mru, &r->objects->packfiles->mru);
}
static void prepare_packed_git(struct repository *r)
@@ -1095,7 +1095,7 @@ struct packed_git *get_all_packs(struct repository *r)
struct list_head *get_packed_git_mru(struct repository *r)
{
prepare_packed_git(r);
return &r->objects->packed_git_mru;
return &r->objects->packfiles->mru;
}
unsigned long unpack_object_header_buffer(const unsigned char *buf,
@@ -2078,10 +2078,10 @@ int find_pack_entry(struct repository *r, const struct object_id *oid, struct pa
if (!r->objects->packfiles->packs)
return 0;
list_for_each(pos, &r->objects->packed_git_mru) {
list_for_each(pos, &r->objects->packfiles->mru) {
struct packed_git *p = list_entry(pos, struct packed_git, mru);
if (!p->multi_pack_index && fill_pack_entry(oid, e, p)) {
list_move(&p->mru, &r->objects->packed_git_mru);
list_move(&p->mru, &r->objects->packfiles->mru);
return 1;
}
}
@@ -2347,6 +2347,7 @@ struct packfile_store *packfile_store_new(struct object_database *odb)
struct packfile_store *store;
CALLOC_ARRAY(store, 1);
store->odb = odb;
INIT_LIST_HEAD(&store->mru);
hashmap_init(&store->map, pack_map_entry_cmp, NULL, 0);
return store;
}