summaryrefslogtreecommitdiff
path: root/oidset.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-06-20 07:41:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-06-20 17:27:48 (GMT)
commit8fbb558af4e911a9507295809a4d1d7d6687b6e1 (patch)
treecb4c73da524f619aff3cda2b4154620f5cc4232f /oidset.c
parent4ed43d16d773ae5f717a258ce81a18ab3fb29435 (diff)
downloadgit-8fbb558af4e911a9507295809a4d1d7d6687b6e1.zip
git-8fbb558af4e911a9507295809a4d1d7d6687b6e1.tar.gz
git-8fbb558af4e911a9507295809a4d1d7d6687b6e1.tar.bz2
khash: rename kh_oid_t to kh_oid_set
khash lets us define a hash as either a map or a set (i.e., with no "value" type). For the oid maps we define, "oid" is the set and "oid_map" is the map. As the bug in the previous commit shows, it's easy to pick the wrong one. So let's make the names more distinct: "oid_set" and "oid_map". An alternative naming scheme would be to actually name the type after the key/value types. So e.g., "oid" _would_ be the set, since it has no value type. And "oid_map" would become "oid_void" or similar (and "oid_pos" becomes "oid_int"). That's better in some ways: it's more regular, and a given map type can be more reasily reused in multiple contexts (e.g., something storing an "int" that isn't a "pos"). But it's also slightly less descriptive. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'oidset.c')
-rw-r--r--oidset.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/oidset.c b/oidset.c
index fe4eb92..8bdecb1 100644
--- a/oidset.c
+++ b/oidset.c
@@ -5,33 +5,33 @@ void oidset_init(struct oidset *set, size_t initial_size)
{
memset(&set->set, 0, sizeof(set->set));
if (initial_size)
- kh_resize_oid(&set->set, initial_size);
+ kh_resize_oid_set(&set->set, initial_size);
}
int oidset_contains(const struct oidset *set, const struct object_id *oid)
{
- khiter_t pos = kh_get_oid(&set->set, *oid);
+ khiter_t pos = kh_get_oid_set(&set->set, *oid);
return pos != kh_end(&set->set);
}
int oidset_insert(struct oidset *set, const struct object_id *oid)
{
int added;
- kh_put_oid(&set->set, *oid, &added);
+ kh_put_oid_set(&set->set, *oid, &added);
return !added;
}
int oidset_remove(struct oidset *set, const struct object_id *oid)
{
- khiter_t pos = kh_get_oid(&set->set, *oid);
+ khiter_t pos = kh_get_oid_set(&set->set, *oid);
if (pos == kh_end(&set->set))
return 0;
- kh_del_oid(&set->set, pos);
+ kh_del_oid_set(&set->set, pos);
return 1;
}
void oidset_clear(struct oidset *set)
{
- kh_release_oid(&set->set);
+ kh_release_oid_set(&set->set);
oidset_init(set, 0);
}