Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: Fix object re-hashing

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:19


On Sun, 12 Feb 2006, Junio C Hamano wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help