]> git.ipfire.org Git - thirdparty/git.git/commitdiff
oidset: make oidset_size() an inline function
authorRené Scharfe <l.s.r@web.de>
Sat, 11 Sep 2021 20:36:40 +0000 (22:36 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 12 Sep 2021 23:14:32 +0000 (16:14 -0700)
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 <peff@peff.net>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
oidset.c
oidset.h

index 5aac633c1f405580447001dfae114660e6120e90..b36a2bae86470236a51ffe6bec7792222de478fe 100644 (file)
--- a/oidset.c
+++ b/oidset.c
@@ -36,11 +36,6 @@ void oidset_clear(struct oidset *set)
        oidset_init(set, 0);
 }
 
-int oidset_size(struct oidset *set)
-{
-       return kh_size(&set->set);
-}
-
 void oidset_parse_file(struct oidset *set, const char *path)
 {
        oidset_parse_file_carefully(set, path, NULL, NULL);
index 01f6560283c38660a010ab84d90c24c9a0219189..ba4a5a2cd3a7a233bc9ca2cb7cf4a58a1e5a122c 100644 (file)
--- 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