Re: [PATCH v8 7/8] cache: add empty_tree_oid object
Jeff King <peff@peff.net> writes:
Show 19 quoted lines
> I suspect we need more than just the "is_empty" query. At least for the
> blob case, we do hashcpy() it into a struct (which should eventually
> become oidcpy). The empty-tree case even more so, as we pass it to
> random functions like lookup_tree().
>
> Our EMPTY_TREE_SHA1_BIN_LITERAL effectively ends up as a singleton
> in-core, too; it's just handled transparently by the compiler, since
> it's a literal. This effectively gives us _two_ singletons. We could do:
>
> const struct object_id empty_blob_oid = {
> "\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b"
> "\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91"
> };
> #define EMPTY_BLOB_SHA1_BIN (empty_blob_oid.hash)
>
> It's possible the use of an actual string literal lets the compiler do
> more optimizations, but I'd doubt it matters in practice. Probably it is
> just sticking that literal somewhere in BSS and filling in the pointer
> to it.