Re: [PATCH 2/5] add object-cache infrastructure
- From
Jeff King <peff@peff.net>
- Date
- Jul 13, 2011, 06:37 UTC
- Message-ID
- <20110713063701.GA18238@sigill.intra.peff.net>
- In-Reply-To
- <7v62n78hpk.fsf@alter.siamese.dyndns.org>
On Tue, Jul 12, 2011 at 11:41:27AM -0700, Junio C Hamano wrote:
Show 14 quoted lines
> Jeff King <peff@peff.net> writes: > > > 2. The disk store uses a binary search over a sorted list of sha1s. > > Generalizing this to "a sequence of bytes" would not be hard. But > > we currently have the option of using the uniform distribution of > > sha1 to make better guesses about our "middle" (see the comments in > > sha1-lookup.c). That assumption does not hold over arbitrary bytes. > > A side note. I notice that the "comment" you refer to appears twice in the > file, and the sha1_pos() function that comes earlier in the file does not > protect itself from overshoot penalty like the sha1_entry_pos() function > does. > > Perhaps we should think about unifying them somehow.
It would be easy to implement sha1_entry_pos in terms of sha1_pos by writing an access function. But it seems unnecessarily slow to add function call overhead in what should be a fairly tight loop.
OTOH, we do it everywhere else that we call sha1_pos; either it isn't a big deal, or nobody has bothered to measure and micro-optimize there yet.
-Peff