Skip to content

Conversation

ethomson
Copy link
Member

@ethomson ethomson commented Oct 1, 2024

Introduce git_hashmap and git_hashset functionality that is a port of khash.h to be more idiomatically libgit2. This gives us many of the benefits of khash that we had abstracted away:

  1. Typesafety on the values, since we define the structs and functions
  2. Ability to create hashes on the stack
  3. Ability to new up hashmaps (or sets) without the libgit2 abstraction wrappers that we had been adding

This uses the macros to define hashes (either the structure, or the functions, or both) which is very much in the spirit of khash, but the results are much more idiomatically libgit2.

This minor refactoring helps remove some of the coupling that pieces
have to the attribute cache.
Let callers understand whether a pool has been initialized or not.
Introduce `git_hashmap` and `git_hashset` functionality that is a port
of `khash.h` to be more idiomatically libgit2. This gives us many of the
benefits of khash that we had abstracted away:

1. Typesafety on the values, since we define the structs and functions
2. Ability to create hashes on the stack
3. Ability to new up hashmaps (or sets) without the libgit2 abstraction
   wrappers that we had been adding

This uses the macros to define hashes (either the structure, or the
functions, or both) which is very much in the spirit of khash, but
the results are much more idiomatically libgit2.
Provide functions for `git_oid` to provide a 32 bit or 64 bit hash
value, useful for a hashmap.
@ethomson ethomson merged commit 5ead0bd into main Oct 2, 2024
19 checks passed
@ethomson ethomson deleted the ethomson/hashmap branch October 2, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant