RFR (S) 8136500: Integer/Long getChars and stringSize should be more idiomatic
Fabian Lange
lange.fabian at gmail.com
Sun Nov 22 19:01:44 UTC 2015
Hi Aleksey,
> > It might be reasonable to reorganize the code a bit:
> >
> > int size = 0, i1 = i;
> > if (i < 0) {
> > if (i == Integer.MIN_VALUE)
> > return "-2147483648";
> > size = 1;
> > i1 = -i;
> > }
> > size += stringSize(i1);
> >
> > First, we would skip one comparison of positive i with MIN_INT.
>
> Yes, I like this one. Grabbed a modified version of this approach.
>
>
Ivan proposed to apply the same comparison order change also to
AbstractStringBuilder#append(int)
I would chime in and also say maybe include also
AbstractStringBuilder#append(long)
Are you willing to include that in your change? Because its essentially the
same code.
Fabian
More information about the core-libs-dev
mailing list