This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: String hashCode
- To: Bryce McKinlay <bryce at albatross dot co dot nz>
- Subject: Re: String hashCode
- From: Tom Tromey <tromey at redhat dot com>
- Date: 31 Jan 2001 18:27:54 -0700
- Cc: java at gcc dot gnu dot org
- References: <3A789EDF.50A39A6C@albatross.co.nz>
- Reply-To: tromey at redhat dot com
>>>>> "Bryce" == Bryce McKinlay <bryce@albatross.co.nz> writes:
Bryce> This would speed up String.equals() by being able to return
Bryce> false quickly in the common case, as well as speeding up things
Bryce> like Hashtables of Strings and string interning.
FYI I've been planning to change the data structure used for
String.intern. I have a patch to do this already; I'll check it in
after the branch is made.
The new data structure is an STL map<> (a red-black tree). I chose
this because it has better worst-case performance than the existing
hash table and is therefore better for real-time usage. The hash
table is bad because rehashing makes the worst case expensive.
Anyway, the new data structure uses String.compareTo and not the hash
code. So speeding it up won't help intern().
Tom