packfile: use a strmap to store packs by name

To allow fast lookups of a packfile by name we use a hashmap that has
the packfile name as key and the pack itself as value. But while this is
the perfect use case for a `strmap`, we instead use `struct hashmap` and
store the hashmap entry in the packfile itself.

Simplify the code by using a `strmap` instead.

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-10-30 11:38:38 +01:00
committed by Junio C Hamano
parent ed3305fff7
commit e78ab37054
2 changed files with 6 additions and 22 deletions

View File

@@ -5,12 +5,12 @@
#include "object.h"
#include "odb.h"
#include "oidset.h"
#include "strmap.h"
/* in odb.h */
struct object_info;
struct packed_git {
struct hashmap_entry packmap_ent;
struct packed_git *next;
struct list_head mru;
struct pack_window *windows;
@@ -85,7 +85,7 @@ struct packfile_store {
* A map of packfile names to packed_git structs for tracking which
* packs have been loaded already.
*/
struct hashmap map;
struct strmap packs_by_path;
/*
* Whether packfiles have already been populated with this store's