Re: Fix object re-hashing

From: Linus Torvalds <torvalds@osdl.org>
Date: 2006-02-13 06:39:58
On Sun, 12 Feb 2006, Junio C Hamano wrote:
> 
> > Btw, as it currently stands, I worry a tiny tiny bit about the
> >
> > 	obj_allocs = (obj_allocs < 32 ? 32 : 2 * obj_allocs)
> >
> > thing, because I think that second "32" needs to be a "64" to be really 
> > safe (ie guarantee that the new obj_allocs value is always at least twice 
> > the old one).
> 
> obj_allocs starts out as 0 so the first value it gets is 32 when
> you need to insert the first element.

Yes. The point being that the code is "conceptually wrong", not that it 
doesn't work in practice. If we somehow could get into the situation that 
we had a hash size of 31, resizing it to 32 would be incorrect.

Of course, if we just make it a rule that the hash size must always be a 
power-of-two (add a comment, and enforce the rule by changing the modulus 
into a bitwise "and"), then that issue too goes away.

			Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Mon Feb 13 06:40:39 2006

This archive was generated by hypermail 2.1.8 : 2006-02-13 06:40:52 EST