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>
René Scharfe committed
Oct 4, 2018 at 17:14 UTC
8c84ae659e0e17d55f5ddc58bc79855ed7650e00
2 files changed
+14
-6
oidset.c
+7
@@ -1,6 +1,13 @@
1
#include "cache.h"
2
#include "oidset.h"
3
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
+
11
int oidset_contains(const struct oidset *set, const struct object_id *oid)
12
{
13
khiter_t pos = kh_get_oid(&set->set, *oid);
oidset.h
+7
-6
@@ -38,12 +38,13 @@ struct oidset {
38
#define OIDSET_INIT { { 0 } }
39
40
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);
48
49
/**
50
* Returns true iff `set` contains `oid`.