Checking the token type seems to be quite slow

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1306663 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2012-03-29 00:58:36 +00:00
parent 810c8d0ae5
commit 19ba389fe8
1 changed files with 5 additions and 1 deletions

View File

@ -136,14 +136,18 @@ class CSVLexer extends Lexer {
* @throws IOException on stream access error
*/
private Token simpleTokenLexer(Token tkn, int c) throws IOException {
while (tkn.type == INVALID) {
// Faster to use while(true)+break than while(tkn.type == INVALID)
while (true) {
if (isEndOfLine(c)) {
tkn.type = EORECORD;
break;
} else if (isEndOfFile(c)) {
tkn.type = EOF;
tkn.isReady = true; // There is data at EOF
break;
} else if (isDelimiter(c)) {
tkn.type = TOKEN;
break;
} else if (isEscape(c)) {
tkn.content.append((char) readEscape());
c = in.read(); // continue