bug report in String.hashCode()

Archie Cobbs archie at whistle.com
Wed Aug 5 14:30:35 PDT 1998


Per Bothner writes:
> > +	boolean hashIsValid;
> > +	int hash;
> > ...
> > +	if (!hashIsValid) {
> > ...
> > +		hashIsValid = true;
> 
> To safe one word in each String, I would suggest:
> 
> 	if (hash == 0 && count > 0)
> 		...
> 
> Very unlikely that you will need to calculate the hash more than once.

Sure.. if you're willing to live with that 1/2^32 chance... :-)

I think you're right. On average you're more likely to go slower because
of extra memory use (-> swapping) than you are because of hitting strings
like "bmgi~ds"...

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com


More information about the kaffe mailing list