Re: Tune String's hashCode() + equals() [was: Need reviewer for forward port of 6815768 (File.getXXXSpace) and 6815768 (String.hashCode)]

2010-03-04 Thread Marek Kozieł
@Ulf Few explanations: 1. > Intersting alternative, but I'm afraid, this is against the spec. > Shifting all 0's to 1 would break String's hash definition: h = 31 * h + > val[i++]. Yes it does, any way i think spec is to tight here. Do we really need hash of each value even if String have length

Re: Tune String's hashCode() + equals() [was: Need reviewer for forward port of 6815768 (File.getXXXSpace) and 6815768 (String.hashCode)]

2010-03-04 Thread Ulf Zibis
Am 04.03.2010 19:33, schrieb Marek Kozieł: Hello, I would suggest: public int hashCode() { int h = hash; if (h == 0) { h = 0; char[] val = value; for (int i = offset, limit = count + i; i != limit; ) h = 31 * h + val[i++];