Ulf Zibis wrote:
Alan,
why don't you take? :
public int hashCode() {
int h = hash;
if (h == 0) {
- int off = offset;
- char val[] = value;
- int len = count; - - for (int i = 0; i < len; i++) {
- h = 31*h + val[off++]; - } - hash
= h;
+ int len = count; + if (len != 0) { + char[] val =
value; + int i = offset; + for (len +=
i; i != len; i++) + h = 31 * h + val[i];
+ hash = h; + } } return h;
-Ulf
The fix we have is fine and eliminates the problematic store (which is
what this bug is about). The method could be re-written as you suggest,
and other ways too but this is slightly beyond the scope of the original
issue (and I said, I'm just bringing forward fixes that we are missing
and not going general String performance work). You are welcome to run
with this, refine your benchmarks, and propose additional patches.
-Alan.