]> git.ipfire.org Git - thirdparty/git.git/commitdiff
khash: move oid hash table definition
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 19 Feb 2019 00:04:53 +0000 (00:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2019 02:57:37 +0000 (11:57 +0900)
Move the oid khash table definition to khash.h and define a typedef for
it, similar to the one we have for unsigned char pointers. Define
variants that are maps as well.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
khash.h
oidset.h

diff --git a/khash.h b/khash.h
index 532109c87f7ce190b5de3e341bafad880238ecad..a09163b3e3beef8fe90f85003aae974411f6998a 100644 (file)
--- a/khash.h
+++ b/khash.h
@@ -332,4 +332,22 @@ typedef kh_sha1_t khash_sha1;
 KHASH_INIT(sha1_pos, const unsigned char *, int, 1, sha1hash, __kh_oid_cmp)
 typedef kh_sha1_pos_t khash_sha1_pos;
 
+static inline unsigned int oid_hash(struct object_id oid)
+{
+       return sha1hash(oid.hash);
+}
+
+static inline int oid_equal(struct object_id a, struct object_id b)
+{
+       return oideq(&a, &b);
+}
+
+KHASH_INIT(oid, struct object_id, int, 0, oid_hash, oid_equal)
+
+KHASH_INIT(oid_map, struct object_id, void *, 1, oid_hash, oid_equal)
+typedef kh_oid_t khash_oid_map;
+
+KHASH_INIT(oid_pos, struct object_id, int, 1, oid_hash, oid_equal)
+typedef kh_oid_pos_t khash_oid_pos;
+
 #endif /* __AC_KHASH_H */
index c9d0f6d3cc8b99959d8637dcbf8ecb235021104e..14f18f791fea19301a41b650b860b0b432241e7a 100644 (file)
--- a/oidset.h
+++ b/oidset.h
  *      table overhead.
  */
 
-static inline unsigned int oid_hash(struct object_id oid)
-{
-       return sha1hash(oid.hash);
-}
-
-static inline int oid_equal(struct object_id a, struct object_id b)
-{
-       return oideq(&a, &b);
-}
-
-KHASH_INIT(oid, struct object_id, int, 0, oid_hash, oid_equal)
-
 /**
  * A single oidset; should be zero-initialized (or use OIDSET_INIT).
  */