From: Junio C Hamano Date: Fri, 17 Apr 2015 21:10:50 GMT Subject: Re: [PATCH v8 1/4] sha1_file.c: support reading from a loose object of unknown type Message-ID: In-Reply-To: <20150417205125.GA7067@peff.net> Jeff King writes: > On Fri, Apr 17, 2015 at 09:21:31AM -0700, Junio C Hamano wrote: > >> Jeff King 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. Yes, that was what I was hoping to see eventually ;-)