提交 ae57979b 编写于 作者: R redestad

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

Reviewed-by: shade, sherman, psandoz
上级 431e9cd6
/*
* 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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册