Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx> writes: > ... > 24 clear_contains_cache > $ > > you will find 24 copies of the commit-slab routines for the contains_cache. > Of course, when you enable optimizations again, these duplicate static > functions (mostly) disappear. Compiling with gcc at -O2, leaves two static > functions, thus: > > $ nm commit-reach.o | grep contains_cache > 0000000000000870 t contains_cache_at_peek.isra.1.constprop.6 > $ nm ref-filter.o | grep contains_cache > 00000000000002b0 t clear_contains_cache.isra.14 > $ > > However, using a shared 'contains_cache' would result in all six of the > above functions as external public functions in the git binary. Sorry, but you lost me here. Where does the 6 in above 'all six' come from? I saw 24 (from unoptimized), and I saw 2 (from optimized), but... Ah, OK, the slab system gives us a familiy of 6 helper functions to deal with the "contains_cache" slab, and we call only 3 of them (i.e. the implementation of other three are left unused). Makes sense. > At present, > only three of these functions are actually called, so the trade-off > seems to favour letting the compiler inline the commit-slab functions. OK. I vaguely recall using a linker that can excise the implementation an unused public function out of the resulting executable in the past, which may tip the balance in the opposite direction, but the above reasonong certainly makes sense to me. > Signed-off-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx> > --- > commit-reach.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/commit-reach.h b/commit-reach.h > index 7d313e2975..f41d8f6ba3 100644 > --- a/commit-reach.h > +++ b/commit-reach.h > @@ -1,12 +1,13 @@ > #ifndef __COMMIT_REACH_H__ > #define __COMMIT_REACH_H__ > > +#include "commit.h" > #include "commit-slab.h" > > -struct commit; > struct commit_list; > -struct contains_cache; > struct ref_filter; > +struct object_id; > +struct object_array; > > struct commit_list *get_merge_bases_many(struct commit *one, > int n,