commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [2/2] [text] No need to nest statement in an else block.
Date Sun, 20 Nov 2016 15:55:30 GMT
No need to nest statement in an else block.

Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/10b97cb5
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/10b97cb5
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/10b97cb5

Branch: refs/heads/master
Commit: 10b97cb5f9e9b599a72d6d165cec851533551567
Parents: fed66c0
Author: Gary Gregory <ggregory@apache.org>
Authored: Sun Nov 20 07:55:25 2016 -0800
Committer: Gary Gregory <ggregory@apache.org>
Committed: Sun Nov 20 07:55:25 2016 -0800

----------------------------------------------------------------------
 .../apache/commons/text/AlphabetConverter.java  | 21 +++++++++-----------
 .../similarity/LevenshteinDetailedDistance.java |  3 +--
 .../text/similarity/LevenshteinDistance.java    |  3 +--
 3 files changed, 11 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/10b97cb5/src/main/java/org/apache/commons/text/AlphabetConverter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/AlphabetConverter.java b/src/main/java/org/apache/commons/text/AlphabetConverter.java
index c5dcf69..0979bec 100644
--- a/src/main/java/org/apache/commons/text/AlphabetConverter.java
+++ b/src/main/java/org/apache/commons/text/AlphabetConverter.java
@@ -158,17 +158,15 @@ public final class AlphabetConverter {
             } else {
                 if (j + encodedLetterLength > encoded.length()) {
                     throw new UnsupportedEncodingException("Unexpected end of string while
decoding " + encoded);
-                } else {
-                    final String nextGroup = encoded.substring(j, j + encodedLetterLength);
-                    final String next = encodedToOriginal.get(nextGroup);
-                    if (next == null) {
-                        throw new UnsupportedEncodingException(
-                                "Unexpected string without decoding (" + nextGroup + ") in
" + encoded);
-                    } else {
-                        result.append(next);
-                        j += encodedLetterLength;
-                    }
                 }
+                final String nextGroup = encoded.substring(j, j + encodedLetterLength);
+                final String next = encodedToOriginal.get(nextGroup);
+                if (next == null) {
+                    throw new UnsupportedEncodingException(
+                            "Unexpected string without decoding (" + nextGroup + ") in "
+ encoded);
+                }
+                result.append(next);
+                j += encodedLetterLength;
             }
         }
 
@@ -452,8 +450,7 @@ public final class AlphabetConverter {
     private static String codePointToString(final int i) {
         if (Character.charCount(i) == 1) {
             return String.valueOf((char) i);
-        } else {
-            return new String(Character.toChars(i));
         }
+        return new String(Character.toChars(i));
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-text/blob/10b97cb5/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
index a913a12..a5d1a5b 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
@@ -100,9 +100,8 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     public LevenshteinResults apply(final CharSequence left, final CharSequence right) {
         if (threshold != null) {
             return limitedCompare(left, right, threshold);
-        } else {
-            return unlimitedCompare(left, right);
         }
+        return unlimitedCompare(left, right);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-text/blob/10b97cb5/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java b/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
index c904adc..e8628be 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
@@ -108,9 +108,8 @@ public class LevenshteinDistance implements EditDistance<Integer>
{
     public Integer apply(final CharSequence left, final CharSequence right) {
         if (threshold != null) {
             return limitedCompare(left, right, threshold);
-        } else {
-            return unlimitedCompare(left, right);
         }
+        return unlimitedCompare(left, right);
     }
 
     /**


Mime
View raw message