< 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: TBD


 477                 }
 478                 if (skipLF) {
 479                     skipLF = false;
 480                     if (c == '\n') {
 481                         continue;
 482                     }
 483                 }
 484                 if (skipWhiteSpace) {
 485                     if (c == ' ' || c == '\t' || c == '\f') {
 486                         continue;
 487                     }
 488                     if (!appendedLineBegin && (c == '\r' || c == '\n')) {
 489                         continue;
 490                     }
 491                     skipWhiteSpace = false;
 492                     appendedLineBegin = false;
 493                 }
 494                 if (isNewLine) {
 495                     isNewLine = false;
 496                     if (c == '#' || c == '!') {














 497                         isCommentLine = true;
 498                         continue;
 499                     }
 500                 }
 501 
 502                 if (c != '\n' && c != '\r') {
 503                     lineBuf[len++] = c;
 504                     if (len == lineBuf.length) {
 505                         int newLength = lineBuf.length * 2;
 506                         if (newLength < 0) {
 507                             newLength = Integer.MAX_VALUE;
 508                         }
 509                         char[] buf = new char[newLength];
 510                         System.arraycopy(lineBuf, 0, buf, 0, lineBuf.length);
 511                         lineBuf = buf;
 512                     }
 513                     //flip the preceding backslash flag
 514                     if (c == '\\') {
 515                         precedingBackslash = !precedingBackslash;
 516                     } else {
 517                         precedingBackslash = false;
 518                     }




 477                 }
 478                 if (skipLF) {
 479                     skipLF = false;
 480                     if (c == '\n') {
 481                         continue;
 482                     }
 483                 }
 484                 if (skipWhiteSpace) {
 485                     if (c == ' ' || c == '\t' || c == '\f') {
 486                         continue;
 487                     }
 488                     if (!appendedLineBegin && (c == '\r' || c == '\n')) {
 489                         continue;
 490                     }
 491                     skipWhiteSpace = false;
 492                     appendedLineBegin = false;
 493                 }
 494                 if (isNewLine) {
 495                     isNewLine = false;
 496                     if (c == '#' || c == '!') {
 497                         // Comment, quickly consume the rest of the line,
 498                         // resume on line-break and backslash.
 499                         while (inOff < inLimit) {
 500                             if (inStream != null) {
 501                                 //The line below is equivalent to calling a
 502                                 //ISO8859-1 decoder.
 503                                 c = (char) (0xff & inByteBuf[inOff++]);
 504                             } else {
 505                                 c = inCharBuf[inOff++];
 506                             }
 507                             if (c == '\n' || c == '\r' || c == '\\') {
 508                                 break;
 509                             }
 510                         }
 511                         isCommentLine = true;

 512                     }
 513                 }
 514 
 515                 if (c != '\n' && c != '\r') {
 516                     lineBuf[len++] = c;
 517                     if (len == lineBuf.length) {
 518                         int newLength = lineBuf.length * 2;
 519                         if (newLength < 0) {
 520                             newLength = Integer.MAX_VALUE;
 521                         }
 522                         char[] buf = new char[newLength];
 523                         System.arraycopy(lineBuf, 0, buf, 0, lineBuf.length);
 524                         lineBuf = buf;
 525                     }
 526                     //flip the preceding backslash flag
 527                     if (c == '\\') {
 528                         precedingBackslash = !precedingBackslash;
 529                     } else {
 530                         precedingBackslash = false;
 531                     }


< prev index next >