8176041: Optimize handling of comment lines in Properties$LineReader.readLine

Reviewed-by: shade, sherman, psandoz
This commit is contained in:
Claes Redestad 2017-03-02 16:18:18 +01:00
parent 6f58cb9f54
commit 91c9c8ef9d

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -471,7 +471,7 @@ class Properties extends Hashtable<Object,Object> {
if (inStream != null) {
//The line below is equivalent to calling a
//ISO8859-1 decoder.
c = (char) (0xff & inByteBuf[inOff++]);
c = (char)(inByteBuf[inOff++] & 0xFF);
} else {
c = inCharBuf[inOff++];
}
@ -494,8 +494,25 @@ class Properties extends Hashtable<Object,Object> {
if (isNewLine) {
isNewLine = false;
if (c == '#' || c == '!') {
// Comment, quickly consume the rest of the line,
// resume on line-break and backslash.
if (inStream != null) {
while (inOff < inLimit) {
byte b = inByteBuf[inOff++];
if (b == '\n' || b == '\r' || b == '\\') {
c = (char)(b & 0xFF);
break;
}
}
} else {
while (inOff < inLimit) {
c = inCharBuf[inOff++];
if (c == '\n' || c == '\r' || c == '\\') {
break;
}
}
}
isCommentLine = true;
continue;
}
}