You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/03/05 18:54:37 UTC

[commons-csv] branch master updated: No need to nest in else.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git


The following commit(s) were added to refs/heads/master by this push:
     new 7df132a  No need to nest in else.
7df132a is described below

commit 7df132a848b9740c0e7c97339e8989b724a4c082
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 5 13:54:34 2021 -0500

    No need to nest in else.
---
 src/main/java/org/apache/commons/csv/Lexer.java | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/csv/Lexer.java b/src/main/java/org/apache/commons/csv/Lexer.java
index 2795ca2..46e9791 100644
--- a/src/main/java/org/apache/commons/csv/Lexer.java
+++ b/src/main/java/org/apache/commons/csv/Lexer.java
@@ -300,14 +300,17 @@ final class Lexer implements Closeable {
                         if (isDelimiter(c)) {
                             token.type = TOKEN;
                             return token;
-                        } else if (isEndOfFile(c)) {
+                        }
+                        if (isEndOfFile(c)) {
                             token.type = EOF;
                             token.isReady = true; // There is data at EOF
                             return token;
-                        } else if (readEndOfLine(c)) {
+                        }
+                        if (readEndOfLine(c)) {
                             token.type = EORECORD;
                             return token;
-                        } else if (!isWhitespace(c)) {
+                        }
+                        if (!isWhitespace(c)) {
                             // error invalid char between token and next delimiter
                             throw new IOException("(line " + getCurrentLineNumber() +
                                     ") invalid char between encapsulated token and delimiter");
@@ -350,14 +353,17 @@ final class Lexer implements Closeable {
             if (readEndOfLine(ch)) {
                 token.type = EORECORD;
                 break;
-            } else if (isEndOfFile(ch)) {
+            }
+            if (isEndOfFile(ch)) {
                 token.type = EOF;
                 token.isReady = true; // There is data at EOF
                 break;
-            } else if (isDelimiter(ch)) {
+            }
+            if (isDelimiter(ch)) {
                 token.type = TOKEN;
                 break;
-            } else if (isEscape(ch)) {
+            }
+            if (isEscape(ch)) {
                 final int unescaped = readEscape();
                 if (unescaped == END_OF_STREAM) { // unexpected char after escape
                     token.content.append((char) ch).append((char) reader.getLastChar());