RFR (S) 8136500: Integer/Long getChars and stringSize should be more idiomatic
Peter Levart
peter.levart at gmail.com
Tue Nov 24 17:22:02 UTC 2015
On 11/24/2015 06:11 PM, Peter Levart wrote:
>> byte r = (byte)((q * 100 - i) & 0x7F);
>> // byte allows the compiler to use byte wide addressing
>> opcodes
>> // which have smaller footprint and are potentially faster
>> // .. & 0x7F may additionally save negative bound check
>> buf[(byte)(--index & 0x7F)] = DigitOnes[r];
>> buf[(byte)(--index & 0x7F)] = DigitTens[r];
>
> ...but index can be large and overflow byte range. Imagine
> concatenating into a String with target length > 127 ...
.. for addressing DigitOnes and DigitTens it is ok and might be faster,
as you say.
If DigitOnes and DigitTens are extended for 28 ignored zero slots, it
may save the upper bound check too.
Regards, Peter
More information about the core-libs-dev
mailing list