commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1299486 - /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
Date Sun, 11 Mar 2012 23:23:37 GMT
Author: ebourg
Date: Sun Mar 11 23:23:37 2012
New Revision: 1299486

URL: http://svn.apache.org/viewvc?rev=1299486&view=rev
Log:
Minor performance improvement (~2%)

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java?rev=1299486&r1=1299485&r2=1299486&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java Sun Mar 11
23:23:37 2012
@@ -317,20 +317,20 @@ class CSVLexer {
         c = in.readAgain();
 
         //  empty line detection: eol AND (last char was EOL or beginning)
-        while (format.isEmptyLinesIgnored() && eol
-                && (lastChar == '\n'
-                || lastChar == '\r'
-                || lastChar == ExtendedBufferedReader.UNDEFINED)
-                && !isEndOfFile(lastChar)) {
-            // go on char ahead ...
-            lastChar = c;
-            c = in.read();
-            eol = isEndOfLine(c);
-            c = in.readAgain();
-            // reached end of file without any content (empty line at the end)
-            if (isEndOfFile(c)) {
-                tkn.type = EOF;
-                return tkn;
+        if (format.isEmptyLinesIgnored()) {
+            while (eol
+                    && (lastChar == '\n' || lastChar == '\r' || lastChar == ExtendedBufferedReader.UNDEFINED)
+                    && !isEndOfFile(lastChar)) {
+                // go on char ahead ...
+                lastChar = c;
+                c = in.read();
+                eol = isEndOfLine(c);
+                c = in.readAgain();
+                // reached end of file without any content (empty line at the end)
+                if (isEndOfFile(c)) {
+                    tkn.type = EOF;
+                    return tkn;
+                }
             }
         }
 
@@ -343,11 +343,14 @@ class CSVLexer {
         //  important: make sure a new char gets consumed in each iteration
         while (!tkn.isReady && tkn.type != EOF) {
             // ignore whitespaces at beginning of a token
-            while (format.isLeadingSpacesIgnored() && isWhitespace(c) &&
!eol) {
-                wsBuf.append((char) c);
-                c = in.read();
-                eol = isEndOfLine(c);
+            if (format.isLeadingSpacesIgnored()) {
+                while (isWhitespace(c) && !eol) {
+                    wsBuf.append((char) c);
+                    c = in.read();
+                    eol = isEndOfLine(c);
+                }
             }
+            
             // ok, start of token reached: comment, encapsulated, or token
             if (c == format.getCommentStart()) {
                 // ignore everything till end of line and continue (incr linecount)



Mime
View raw message