hg: jdk7/tl/jdk: 2 new changesets
Alan Bateman
Alan.Bateman at Sun.COM
Sun Feb 28 15:24:50 UTC 2010
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20100228/94bf6988/attachment.html>
More information about the core-libs-dev
mailing list