< prev index next >

src/java.base/share/classes/java/util/Properties.java

Print this page
rev 16769 : 8176041: Optimize handling of comment lines in Properties$LineReader.readLine
Reviewed-by: shade

*** 492,503 **** appendedLineBegin = false; } if (isNewLine) { isNewLine = false; if (c == '#' || c == '!') { isCommentLine = true; - continue; } } if (c != '\n' && c != '\r') { lineBuf[len++] = c; --- 492,520 ---- appendedLineBegin = false; } 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)(0xff & b); + break; + } + } + } else { + while (inOff < inLimit) { + c = inCharBuf[inOff++]; + if (c == '\n' || c == '\r' || c == '\\') { + break; + } + } + } isCommentLine = true; } } if (c != '\n' && c != '\r') { lineBuf[len++] = c;
< prev index next >