RE: https://issues.apache.org/jira/browse/HARMONY-6404
I posted up two proposed patches for String, please comment on which is preferable. One is the change previously mentioned, the other is a slightly bigger reorganization. -Nathan On Sat, Dec 19, 2009 at 4:04 AM, Egor Pasko <egor.pa...@gmail.com> wrote: > On the 0x68A day of Apache Harmony Tim Ellison wrote: >> On 12/Dec/2009 10:54, Egor Pasko wrote: >>> On the 0x685 day of Apache Harmony Nathan Beyer wrote: >> <snip> >>>> In any case, it does seem a pinch more efficient to only do one read >>>> of hashCode ... switch up the code to be something like this. >>>> >>>> public int hashCode() { >>>> final int hash = hashCode; >>>> if (hash == 0) { >>>> if (count == 0) { >>>> return 0; >>>> } >>>> for (int i = offset; i < count + offset; i++) { >>>> hash = value[i] + ((hash << 5) - hash); >>>> } >>>> hashCode = hash; >>> >>> one more 'return hash' here, please :) >> >> Why? > > argh, what was I thinking about? the original Nathan's code is great. > > -- > Egor Pasko > >