RFR: 8221836: Avoid recalculating String.hash when zero

Claes Redestad claes.redestad at oracle.com
Mon Apr 8 16:26:51 UTC 2019


Hi Ivan,

not sure that would be an optimization, since you'd trade a conditional
write for an unconditional one. The computation itself for the empty
string has trivial cost.

/Claes

On 2019-04-08 18:12, Ivan Gerasimov wrote:
> Hi Claes!
> 
> Would it make sense to preset hashIsZero = true in the empty string 
> constructor?
> 
> The current code avoids calculating the hashCode for an empty string, 
> and the new code doesn't seem to do that because hashIsZero = false by 
> default for each newly constructed copy of the empty string.
> 
> With kind regards,
> Ivan



More information about the hotspot-gc-dev mailing list