Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-02-19 03:04:53 +0300
committerJunio C Hamano <gitster@pobox.com>2019-04-01 05:57:37 +0300
commit5a8643eff1e59f1cf96da9875d5716e88f480710 (patch)
tree6522b331529f0a7413fb54a2fc301a6e2d3031a1 /khash.h
parent76c23892bcbc5e8fba1f6d844b05752082d0542e (diff)
khash: move oid hash table definition
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>
Diffstat (limited to 'khash.h')
-rw-r--r--khash.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/khash.h b/khash.h
index 532109c87f..a09163b3e3 100644
--- 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 */