Skip to content

Commit 325006f

Browse files
rscharfegitster
authored andcommitted
oidset: make oidset_size() an inline function
oidset_size() just reads a single word from memory and returns it. Avoid the function call overhead for this trivial operation by turning it into an inline function. While we're at it, declare its parameter const to allow it to be used on read-only oidsets. Suggested-by: Jeff King <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b7c11b commit 325006f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

oidset.c

-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ 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-
4439
void oidset_parse_file(struct oidset *set, const char *path)
4540
{
4641
oidset_parse_file_carefully(set, path, NULL, NULL);

oidset.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ int oidset_remove(struct oidset *set, const struct object_id *oid);
5757
/**
5858
* Returns the number of oids in the set.
5959
*/
60-
int oidset_size(struct oidset *set);
60+
static inline int oidset_size(const struct oidset *set)
61+
{
62+
return kh_size(&set->set);
63+
}
6164

6265
/**
6366
* Remove all entries from the oidset, freeing any resources associated with

0 commit comments

Comments
 (0)