[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ihash ids should be unsigned
From: |
Marcus Brinkmann |
Subject: |
Re: [PATCH] ihash ids should be unsigned |
Date: |
Sun, 17 Aug 2003 05:29:50 +0200 |
User-agent: |
Mutt/1.5.4i |
On Sat, Aug 16, 2003 at 09:29:22PM -0400, Roland McGrath wrote:
> > I also want to remove ihash/primes.c which is obsolete but wasn't removed at
> > the time Roland replaced it by sizes.c. The file will still be in the
> > repository, of course (under Attic).
>
> Fine.
BTW, the table is wrong, because it starts with 2. An even number will not
guarantee that the table will be used completely (the hash of an even key is
0, and so is the rehash). The smallest number that makes this guarantee is
1, although it is not prime. The smalles odd prime is of course 3, but
that would mean we would have to change the comment or generate a wholly new
sequence (3, 7, 17, 37, 79, ...), which is ok. It's simpler to just start
with 5, though. Allocating 5 objects as soon as the first object is added
should in fact be an improvement, because most hashes will not be populated
with 5 or less objects, but with more. So we'd save one repopulation.
I propose to just get rid off the 2, maybe even the 5. Alternatively,
change the start value of I in the loop that searches for the next element.
Thanks,
Marcus
--
`Rhubarb is no Egyptian god.' GNU http://www.gnu.org address@hidden
Marcus Brinkmann The Hurd http://www.gnu.org/software/hurd/
address@hidden
http://www.marcus-brinkmann.de/