Skip to content

Commit f478106

Browse files
ttaylorrgitster
authored andcommitted
oidset: introduce 'oidset_size'
Occasionally, it may be useful for callers to know the number of object IDs in an oidset. Right now, the only way to compute this is to call 'kh_size' on the internal 'kh_set_oid_t'. Similar to how we wrap other 'kh_*' functions over the 'oidset' type, let's allow callers to compute this value by introducing 'oidset_size'. We will add its first caller in the subsequent commit. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8a6ac28 commit f478106

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

oidset.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ void oidset_clear(struct oidset *set)
3636
oidset_init(set, 0);
3737
}
3838

39+
int oidset_size(struct oidset *set)
40+
{
41+
return kh_size(&set->set);
42+
}
43+
3944
void oidset_parse_file(struct oidset *set, const char *path)
4045
{
4146
FILE *fp;

oidset.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ int oidset_insert(struct oidset *set, const struct object_id *oid);
5555
*/
5656
int oidset_remove(struct oidset *set, const struct object_id *oid);
5757

58+
/**
59+
* Returns the number of oids in the set.
60+
*/
61+
int oidset_size(struct oidset *set);
62+
5863
/**
5964
* Remove all entries from the oidset, freeing any resources associated with
6065
* it.

0 commit comments

Comments
 (0)