commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1306663 - /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java
Date Thu, 29 Mar 2012 00:58:36 GMT
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



Mime
View raw message