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 <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2018-10-04 17:14:37 +02:00 committed by Junio C Hamano
parent 8b2f8cbcb1
commit 8c84ae659e
2 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,13 @@
#include "cache.h" #include "cache.h"
#include "oidset.h" #include "oidset.h"
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);
}
int oidset_contains(const struct oidset *set, const struct object_id *oid) 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, *oid);

View File

@ -38,12 +38,13 @@ struct oidset {
#define OIDSET_INIT { { 0 } } #define OIDSET_INIT { { 0 } }
static inline void oidset_init(struct oidset *set, size_t initial_size) /**
{ * Initialize the oidset structure `set`.
memset(&set->set, 0, sizeof(set->set)); *
if (initial_size) * If `initial_size` is bigger than 0 then preallocate to allow inserting
kh_resize_oid(&set->set, initial_size); * the specified number of elements without further allocations.
} */
void oidset_init(struct oidset *set, size_t initial_size);
/** /**
* Returns true iff `set` contains `oid`. * Returns true iff `set` contains `oid`.