From 325006f2dbeb482f422b2c0e62b485a41cb1c64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 11 Sep 2021 22:36:40 +0200 Subject: oidset: make oidset_size() an inline function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- oidset.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'oidset.h') diff --git a/oidset.h b/oidset.h index 01f6560283..ba4a5a2cd3 100644 --- a/oidset.h +++ b/oidset.h @@ -57,7 +57,10 @@ int oidset_remove(struct oidset *set, const struct object_id *oid); /** * Returns the number of oids in the set. */ -int oidset_size(struct oidset *set); +static inline int oidset_size(const struct oidset *set) +{ + return kh_size(&set->set); +} /** * Remove all entries from the oidset, freeing any resources associated with -- cgit v1.2.3