From: Karthik Nayak Date: Fri, 14 Aug 2026 10:21:54 GMT Subject: Re: [PATCH v2 1/4] odb: decouple source path comparisons from `the_repository` Message-ID: In-Reply-To: Patrick Steinhardt writes: > On Thu, Aug 13, 2026 at 05:23:39AM -0700, Karthik Nayak wrote: >> Patrick Steinhardt writes: >> > diff --git a/odb.c b/odb.c >> > index bd02d8ad54..51da386f22 100644 >> > --- a/odb.c >> > +++ b/odb.c >> > @@ -29,8 +28,32 @@ >> > #include "trace2.h" >> > #include "write-or-die.h" >> > >> > -KHASH_INIT(odb_path_map, const char * /* key: odb_path */, >> > - struct odb_source *, 1, fspathhash, fspatheq) >> > +static int odb_source_paths_cmp(struct object_database *o, >> > + const char *a, const char *b) >> > +{ >> > + if (o->source_paths_icase < 0) { >> > + int icase = 0; >> > + repo_config_get_bool(o->repo, "core.ignorecase", &icase); >> > + o->source_paths_icase = icase; >> > + } >> > + >> >> Nit: couldn't this be simplified to >> >> if (o->source_paths_icase < 0) >> repo_config_get_bool(o->repo, "core.ignorecase", &o->source_paths_icase); > > Not quite, as that wouldn't handle the case where the configuration > isn't set. So we'd retain it as -1 and do the config lookup every single > time. > > We could rewrite like this: > > if (o->source_paths_icase < 0 && > repo_config_get_bool(o->repo, "core.ignorecase", &icase)) > o->source_paths_icase = 0; > > But I'd argue that this is harder to read. > > Patrick Ooh, yes, makes sense. It's better as is :)