Did you check the performance with this change? The last time I tried to
remove the breaks it was slower.
Emmanuel Bourg
Le 28/03/2012 02:34, s...@apache.org a écrit :
Author: sebb
Date: Wed Mar 28 00:34:27 2012
New Revision: 1306079
URL: http://svn.apache.org/viewvc?rev=1306079&view=rev
Log:
CSV-70 Improve readability of CSVLexer
Simplify; remove while(true) loop
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=1306079&r1=1306078&r2=1306079&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
Wed Mar 28 00:34:27 2012
@@ -133,27 +133,21 @@ class CSVLexer extends Lexer {
* @throws IOException on stream access error
*/
private Token simpleTokenLexer(Token tkn, int c) throws IOException {
- while (true) {
+ while (tkn.type == INVALID) {
if (isEndOfLine(c)) {
- // end of record
tkn.type = EORECORD;
- break;
} else if (isEndOfFile(c)) {
- // end of file
tkn.type = EOF;
tkn.isReady = true; // There is data at EOF
- break;
} else if (isDelimiter(c)) {
- // end of token
tkn.type = TOKEN;
- break;
} else if (isEscape(c)) {
tkn.content.append((char) readEscape());
+ c = in.read(); // continue
} else {
tkn.content.append((char) c);
+ c = in.read(); // continue
}
-
- c = in.read();
}
if (surroundingSpacesIgnored) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org