RFR: 8224202: Speed up Properties.load
Roger Riggs
Roger.Riggs at oracle.com
Thu May 23 14:42:22 UTC 2019
Hi Claes,
Looking good.
Is there any performance benefit to using ?: instead of if..else at
Line 509-515 c = (fromStream) ? (char) (byteBuf[off++] & 0xFF) :
charBuf[off++];
Line 578-581: precedingBackslash = (c == '\\') ? !precedingBackslash :
false;
Line 600: add 'the" to "characters in +the+ following line"
Thanks, Roger
On 05/23/2019 08:57 AM, Claes Redestad wrote:
> Hi Ivan!
>
> On 2019-05-23 02:11, Ivan Gerasimov wrote:
>> Hi Claes!
>>
>> A few comments:
>>
>> 1)
>>
>> 571 if (len == lineBuf.length) {
>> 572 int newLength =
>> ArraysSupport.newLength(lineBuf.length, 1, lineBuf.length);
>>
>> could be written slightly shorter as
>>
>> 571 if (len == lineBuf.length) {
>> 572 int newLength =
>> ArraysSupport.newLength(len, 1, len);
>>
>> 2)
>> 585 if (len == 0) {
>> 586 skipWhiteSpace = true;
>> 587 len = 0;
>>
>> no need to update len here
>
> nice catches, fixed.
>
>>
>> 3)
>> In loadConvert(char[] in, int off, int len, StringBuilder out):
>>
>> It may make sense to first scan the input buffer for backslash, and
>> if not found (should be a common case), return new String(in, off,
>> len), so a copying to the StringBuilder will be avoided.
>>
>> Otherwise:
>> out.append(in, off, posOfSlash - off);
>> off = posOfSlash;
>>
>> and continue as before...
>
> Right, this got a bit murky since String(char[], int, int) runs through
> a noisy compress method and execute more bytecode in profiles. Still it
> comes out a bit faster in a few real measurements, probably due to doing
> fewer calls from interpreter to compiled code in the end:
>
> http://cr.openjdk.java.net/~redestad/8224202/open.03/
>
> Thanks!
>
> /Claes
More information about the core-libs-dev
mailing list