From 8c84ae659e0e17d55f5ddc58bc79855ed7650e00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 4 Oct 2018 17:14:37 +0200 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- oidset.c | 7 +++++++ oidset.h | 13 +++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/oidset.c b/oidset.c index 9836d427ef..fe4eb921df 100644 --- a/oidset.c +++ b/oidset.c @@ -1,6 +1,13 @@ #include "cache.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) { khiter_t pos = kh_get_oid(&set->set, *oid); diff --git a/oidset.h b/oidset.h index 4b90540cd4..c9d0f6d3cc 100644 --- a/oidset.h +++ b/oidset.h @@ -38,12 +38,13 @@ struct oidset { #define OIDSET_INIT { { 0 } } -static inline 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); -} +/** + * Initialize the oidset structure `set`. + * + * If `initial_size` is bigger than 0 then preallocate to allow inserting + * the specified number of elements without further allocations. + */ +void oidset_init(struct oidset *set, size_t initial_size); /** * Returns true iff `set` contains `oid`. -- 2.47.1