Merge branch 'dl/complete-cherry-pick-revert-skip'
[gitweb.git] / khash.h
diff --git a/khash.h b/khash.h
index 3d25667a823487f9703ae270600f72529189f1b9..21c2095216cb5dcb8be372d82443a8dd1c1435c8 100644 (file)
--- a/khash.h
+++ b/khash.h
@@ -69,11 +69,11 @@ static const double __ac_HASH_UPPER = 0.77;
                khval_t *vals; \
        } kh_##name##_t;
 
-#define __KHASH_PROTOTYPES(name, khkey_t, khval_t)                                             \
-       kh_##name##_t *kh_init_##name(void);                                                    \
+#define __KHASH_PROTOTYPES(name, khkey_t, khval_t)                             \
+       kh_##name##_t *kh_init_##name(void);                                            \
        void kh_destroy_##name(kh_##name##_t *h);                                       \
        void kh_clear_##name(kh_##name##_t *h);                                         \
-       khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key);     \
+       khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
        int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
        khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
        void kh_del_##name(kh_##name##_t *h, khint_t x);
@@ -324,12 +324,20 @@ static const double __ac_HASH_UPPER = 0.77;
                code;                                                                                           \
        } }
 
-#define __kh_oid_cmp(a, b) (hashcmp(a, b) == 0)
+static inline unsigned int oidhash_by_value(struct object_id oid)
+{
+       return oidhash(&oid);
+}
+
+static inline int oideq_by_value(struct object_id a, struct object_id b)
+{
+       return oideq(&a, &b);
+}
+
+KHASH_INIT(oid_set, struct object_id, int, 0, oidhash_by_value, oideq_by_value)
 
-KHASH_INIT(sha1, const unsigned char *, void *, 1, sha1hash, __kh_oid_cmp)
-typedef kh_sha1_t khash_sha1;
+KHASH_INIT(oid_map, struct object_id, void *, 1, oidhash_by_value, oideq_by_value)
 
-KHASH_INIT(sha1_pos, const unsigned char *, int, 1, sha1hash, __kh_oid_cmp)
-typedef kh_sha1_pos_t khash_sha1_pos;
+KHASH_INIT(oid_pos, struct object_id, int, 1, oidhash_by_value, oideq_by_value)
 
 #endif /* __AC_KHASH_H */