Need reviewer for forward port of 6815768 (File.getXXXSpace) and 6815768 (String.hashCode)

Jason Mehrens jason_mehrens at hotmail.com
Thu Mar 4 02:08:46 UTC 2010


String.hash should only have two known states, zero and the actual computed hash code.

 

http://bugs.sun.com/view_bug.do?bug_id=6611830

 

Jason


 
> Date: Sun, 28 Feb 2010 17:09:15 +0100
> From: Ulf.Zibis at gmx.de
> To: Alan.Bateman at Sun.COM
> Subject: Re: Need reviewer for forward port of 6815768 (File.getXXXSpace) and 6815768 (String.hashCode)
> CC: core-libs-dev at openjdk.java.net; dmitry.nadezhin at gmail.com; Kelly.Ohair at Sun.COM
> 
> Another thought:
> 
> In the constructors of String we could initialize hash = 
> Integer.MIN_VALUE except if length == 0.
> Then we could stay at the fastest version:
> 
> public int hashCode() {
> int h = hash;
> if (h == Integer.MIN_VALUE) {
> h = 0;
> char[] val = value;
> for (int i = offset, limit = count + i; i != limit; )
> h = 31 * h + val[i++];
> hash = h;
> }
> return h;
> }
 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/201469226/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20100303/a7c668ba/attachment.html>


More information about the core-libs-dev mailing list