harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: [jira] Created: (HARMONY-6404) possible data-reordering in some hashCode-methods (e.g. String or URL)
Date Thu, 17 Dec 2009 09:31:14 GMT
On 12/Dec/2009 10:54, Egor Pasko wrote:
> On the 0x685 day of Apache Harmony Nathan Beyer wrote:
<snip>
>> In any case, it does seem a pinch more efficient to only do one read
>> of hashCode ... switch up the code to be something like this.
>>
>> public int hashCode() {
>>     final int hash = hashCode;
>>     if (hash == 0) {
>>         if (count == 0) {
>>             return 0;
>>         }
>>         for (int i = offset; i < count + offset; i++) {
>>             hash = value[i] + ((hash << 5) - hash);
>>         }
>>         hashCode = hash;
> 
> one more 'return hash' here, please :)

Why?

>>     }
>>     return hash;
>> }


Mime
View raw message