Re: [PATCH v8 1/4] sha1_file.c: support reading from a loose object of unknown type
- From
Jeff King <peff@peff.net>
- Date
- Apr 17, 2015, 20:51 UTC
- Message-ID
- <20150417205125.GA7067@peff.net>
- In-Reply-To
- <xmqqd232hgj8.fsf@gitster.dls.corp.google.com>
On Fri, Apr 17, 2015 at 09:21:31AM -0700, Junio C Hamano wrote:
Show 6 quoted lines
> Jeff King <peff@peff.net> writes: > > > If there _is_ a performance implication to worry about here, I think it > > would be that we are doing an extra malloc/free. > > Thanks for reminding me; yes, that also worried me.
As an aside, I worried about the extra allocation for reading the header in the first place. But it looks like we only do this on the --literally code path (and otherwise use the normal unpack_sha1_header). Still, I wonder if we could make this work automagically. That is, speculatively unpack the first N bytes, assuming we hit the end-of-header. If not, then go to a strbuf as the slow path. Then it would be fine to cover all cases; the normal ones would be fast, and only ridiculous things would incur the extra allocation.
-Peff