From: Karthik Nayak Date: Thu, 09 Apr 2026 09:40:01 GMT Subject: Re: [PATCH v2 04/17] odb/source-inmemory: implement `read_object_info()` callback Message-ID: In-Reply-To: <20260409-b4-pks-odb-source-inmemory-v2-4-f02b4f1c0f13@pks.im> Patrick Steinhardt writes: [snip] > diff --git a/odb/source-inmemory.c b/odb/source-inmemory.c > index ccbb622eae..12c80f9b34 100644 > --- a/odb/source-inmemory.c > +++ b/odb/source-inmemory.c > @@ -1,5 +1,57 @@ > #include "git-compat-util.h" > +#include "odb.h" > #include "odb/source-inmemory.h" > +#include "repository.h" > + > +static const struct cached_object *find_cached_object(struct odb_source_inmemory *source, > + const struct object_id *oid) > +{ > + static const struct cached_object empty_tree = { > + .type = OBJ_TREE, > + .buf = "", > + }; > + const struct cached_object_entry *co = source->objects; > + > + for (size_t i = 0; i < source->objects_nr; i++, co++) > + if (oideq(&co->oid, oid)) > + return &co->value; > + > + if (oid->algo && oideq(oid, hash_algos[oid->algo].empty_tree)) > + return &empty_tree; > + Silly questiong, would it make more sense to check for empty_tree before iterating over all objects? The rest looks good [snip]