commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [lang] Make code more readable with less nesting (move block out of else clause).
Date Thu, 25 May 2017 16:25:58 GMT
Repository: commons-lang
Updated Branches:
  refs/heads/master ef3015cc9 -> 6a688cf36


Make code more readable with less nesting (move block out of else
clause).

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/6a688cf3
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/6a688cf3
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/6a688cf3

Branch: refs/heads/master
Commit: 6a688cf36e23aded8c9796b786e92144cb4a5830
Parents: ef3015c
Author: Gary Gregory <ggregory@apache.org>
Authored: Thu May 25 09:25:56 2017 -0700
Committer: Gary Gregory <ggregory@apache.org>
Committed: Thu May 25 09:25:56 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/commons/lang3/CharSetUtils.java   | 14 ++++++--------
 .../org/apache/commons/lang3/math/NumberUtils.java    |  3 +--
 .../java/org/apache/commons/lang3/text/WordUtils.java |  3 +--
 3 files changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/6a688cf3/src/main/java/org/apache/commons/lang3/CharSetUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/CharSetUtils.java b/src/main/java/org/apache/commons/lang3/CharSetUtils.java
index 84c1d09..015eeb8 100644
--- a/src/main/java/org/apache/commons/lang3/CharSetUtils.java
+++ b/src/main/java/org/apache/commons/lang3/CharSetUtils.java
@@ -78,15 +78,13 @@ public class CharSetUtils {
             if (ch == lastChar) {
                 if (inChars != null && ch == inChars) {
                     continue;
-                } else {
-                    if (notInChars == null || ch != notInChars) {
-                        if (chars.contains(ch)) {
-                            inChars = ch;
-                            continue;
-                        } else {
-                            notInChars = ch;
-                        }
+                }
+                if (notInChars == null || ch != notInChars) {
+                    if (chars.contains(ch)) {
+                        inChars = ch;
+                        continue;
                     }
+                    notInChars = ch;
                 }
             }
             buffer.append(ch);

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/6a688cf3/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
index f77bf10..0d512fe 100644
--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
@@ -1542,9 +1542,8 @@ public class NumberUtils {
                 return false;
             }
             return withDecimalsParsing(str, 1);
-        } else {
-            return withDecimalsParsing(str, 0);
         }
+        return withDecimalsParsing(str, 0);
     }
 
     private static boolean withDecimalsParsing(final String str, final int beginIdx) {

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/6a688cf3/src/main/java/org/apache/commons/lang3/text/WordUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/text/WordUtils.java b/src/main/java/org/apache/commons/lang3/text/WordUtils.java
index 16ae683..66ce445 100644
--- a/src/main/java/org/apache/commons/lang3/text/WordUtils.java
+++ b/src/main/java/org/apache/commons/lang3/text/WordUtils.java
@@ -293,9 +293,8 @@ public class WordUtils {
                 if (matcher.start() == 0) {
                     offset += matcher.end();
                     continue;
-                }else {
-                    spaceToWrapAt = matcher.start() + offset;
                 }
+                spaceToWrapAt = matcher.start() + offset;
             }
 
             // only last line without leading spaces is left


Mime
View raw message