Re: [PATCH v2 04/17] odb/source-inmemory: implement `read_object_info()` callback
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Apr 9, 2026, 09:40 UTC
- Message-ID
- <CAOLa=ZRwv_NYqtNyvhi=5auLhVx+FDbt+RP6Kj_ZqjF=VsefyA@mail.gmail.com>
- In-Reply-To
- <20260409-b4-pks-odb-source-inmemory-v2-4-f02b4f1c0f13@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
[snip]
Show 26 quoted lines
> 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]