I found two alternatives in the link http://mail.openjdk.java.net/pipermail/coin-dev/2009-December/002618.html
The first alternative int equalByHashThreshold = 2; public boolean equals(Object anObject) { if (this == anObject) { return true; } if (anObject instanceof String) { String anotherString = (String)anObject; int n = count; if (n == anotherString.count && (equalByHashThreshold == 0 || --equalByHashThreshold == 0) && (anotherString.equalByHashThreshold == 0 || --anotherString.equalByHashThreshold == 0) && hash() == anotherString.hash()) { [snipped] } } return false; } will say that "A".equals("A") == false because body of if statement will not be executed The second alternative public int hashCode() { int h = hash; if (h == 0 || --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; } return h; } will return sequentially "A".hashCode() == 65 "A".hashCode() == 64 "A".hashCode() == 64 . . . I guess that you mean something else. -Dima On Fri, Feb 26, 2010 at 1:19 PM, Ulf Zibis <ulf.zi...@gmx.de> wrote: > Have you seen, that there are some chances to make String#equals little > faster too: > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6912520 > > -Ulf > > > Am 25.02.2010 23:07, schrieb Alan Bateman: > >> Kelly O'Hair wrote: >> >>> Yup. My eyes must be tired, I didn't see that. :^( >>> >> Too many repositories in the air at the same time. The webrev has been >> refreshed. Thanks Ulf. >> >> >> >