[Mono-list] mcs compiles on linux. Now what?

Radek Doulík rodo@ximian.com
07 Mar 2002 19:13:47 -0500


On Čt, 2002-03-07 at 17:31, Dan Lewis wrote:
>  --- Paolo Molaro <lupus@ximian.com> wrote:
> > System.Collections.Hashtable::Find() takes more than 40% of the compile
> > This suggest we may be using bad hash functions or that the hashtable
> > doesn't resize correctly, since the average compare per lookup is
> > greater than 5 (it should be about 1). So check the sources for
> > bad GetHashCode() implementations, create tests to check that the
> > hashtable behaves correctly when expanding.
> 
> I seem to remember the default GetHashCode() implementation returns 0 (a
> perfect hash function -- if there's only one key :). Would it be possible to
> implement Object.GetHashCode() as an internal call? (a shallow hash based on
> the object bits).

Which bits do you mean? As a temporary solution we could have static int
counter in Object class and instance int variable, which will be set by
counter value in constructor? Like this:

class Object {
	static int counter = 0;
	private int key;

	public Object ()
	{
		key = counter;
		counter ++;
	}

	public virtual int GetHashCode ()
	{
		return key;
	}
}

Which could serve before we could find something better. Actually I am
not sure, how this works for boxed objects, maybe we cannot have
instance variable in Object because boxing?

Cheers
Radek