Skip to content

Commit 8c84ae6

Browse files
rscharfegitster
authored andcommitted
oidset: uninline oidset_init()
There is no need to inline oidset_init(), as it's typically only called twice in the lifetime of an oidset (once at the beginning and at the end by oidset_clear()) and kh_resize_* is quite big, so move its definition to oidset.c. Document it while we're at it. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b2f8cb commit 8c84ae6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

oidset.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#include "cache.h"
22
#include "oidset.h"
33

4+
void oidset_init(struct oidset *set, size_t initial_size)
5+
{
6+
memset(&set->set, 0, sizeof(set->set));
7+
if (initial_size)
8+
kh_resize_oid(&set->set, initial_size);
9+
}
10+
411
int oidset_contains(const struct oidset *set, const struct object_id *oid)
512
{
613
khiter_t pos = kh_get_oid(&set->set, *oid);

oidset.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ struct oidset {
3838
#define OIDSET_INIT { { 0 } }
3939

4040

41-
static inline void oidset_init(struct oidset *set, size_t initial_size)
42-
{
43-
memset(&set->set, 0, sizeof(set->set));
44-
if (initial_size)
45-
kh_resize_oid(&set->set, initial_size);
46-
}
41+
/**
42+
* Initialize the oidset structure `set`.
43+
*
44+
* If `initial_size` is bigger than 0 then preallocate to allow inserting
45+
* the specified number of elements without further allocations.
46+
*/
47+
void oidset_init(struct oidset *set, size_t initial_size);
4748

4849
/**
4950
* Returns true iff `set` contains `oid`.

0 commit comments

Comments
 (0)