Benefit from computing String Hash at compile time?

Joseph D. Darcy Joe.Darcy at Sun.COM
Mon Jan 4 15:52:20 PST 2010


Jonathan Gibbons wrote:
> Alexander Veit wrote:
>   
>> Hi Jonathan,
>>
>>   
>>     
>>> The fact is, the spec is set in stone, *and* covered by conformance 
>>> tests.  The chance of the spec changing is vanishingly small, and the 
>>> conformance tests ensure that all implementations of Java must follow 
>>> the spec.
>>>     
>>>       
>> Calculating String#hashCode() is quite costly in terms of CPU cycles. If a
>> better performing method with comparable quality would come to our
>> knowledge, the chance of changing the spec would probably be greater than e
>>   
>>     
>>> 0.
>>>     
>>>       
>
> Alex,
>
> You are missing the point.   The spec doesn't mandate "a jolly good hash 
> function" with enough wiggle room to allow "a jolly better one" if and 
> when we think of one. The spec mandates a specific formula. 

And implicit in mandating that formula is mandating that formula going 
forward for all subsequent releases.  Otherwise, there is often not much 
point in specifying a particular hash function.

-Joe




More information about the coin-dev mailing list