]> git.ipfire.org Git - thirdparty/git.git/commit
refs: track ref stores via strmap
authorPatrick Steinhardt <ps@pks.im>
Fri, 17 May 2024 08:18:28 +0000 (10:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 May 2024 17:33:37 +0000 (10:33 -0700)
commitf1782d185b03db37412f47a013400b0693fd97bd
tree26e5942668531a0ad82195cc473cd53caebbffc4
parent71c871b48dfaf300ca20e205917db72ab9c6d7b3
refs: track ref stores via strmap

The refs code has two global maps that track the submodule and worktree
ref stores. Even though both of these maps track values by strings, we
still use a `struct hashmap` instead of a `struct strmap`. This has the
benefit of saving us an allocation because we can combine key and value
in a single struct. But it does introduce significant complexity that is
completely unneeded.

Refactor the code to use `struct strmap`s instead to reduce complexity.
It's unlikely that this will have any real-world impact on performance
given that most repositories likely won't have all that many ref stores.
Furthermore, this refactoring allows us to de-globalize those maps and
move them into `struct repository` in a subsequent commit more easily.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c