You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/03/29 02:58:36 UTC
svn commit: r1306663 -
/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java
Author: sebb
Date: Thu Mar 29 00:58:36 2012
New Revision: 1306663
URL: http://svn.apache.org/viewvc?rev=1306663&view=rev
Log:
Checking the token type seems to be quite slow
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java
Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java?rev=1306663&r1=1306662&r2=1306663&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java Thu Mar 29 00:58:36 2012
@@ -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