[jsemver] 08/95: Refactor previous commit; remove duplications

Alexandre Viau reazem-guest at moszumanska.debian.org
Mon Feb 16 14:58:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

reazem-guest pushed a commit to branch master
in repository jsemver.

commit 7b4e653723fe8cab56b40c87e738f558ed71436b
Author: Zafar Khaja <zafarkhaja at gmail.com>
Date:   Tue Nov 27 22:00:08 2012 +0400

    Refactor previous commit; remove duplications
---
 .../java/com/github/zafarkhaja/semver/Version.java | 27 ++++++++--------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/github/zafarkhaja/semver/Version.java b/src/main/java/com/github/zafarkhaja/semver/Version.java
index 06a998d..54da22e 100644
--- a/src/main/java/com/github/zafarkhaja/semver/Version.java
+++ b/src/main/java/com/github/zafarkhaja/semver/Version.java
@@ -173,40 +173,31 @@ public class Version implements Comparable<Version> {
     }
     
     private int comparePreReleaseVersions(Version other) {
-        int result;
-        if (preReleaseVersion == null && 
-                other.getPreReleaseVersion() == null) {
-            result = 0;
-        } else if (preReleaseVersion == null || 
-                other.getPreReleaseVersion() == null) {
-            result = preReleaseVersion == null ? 1 : -1;
+        if (preReleaseVersion == null ^ other.getPreReleaseVersion() == null) {
+            return preReleaseVersion == null ? 1 : -1;
         } else {
-            result = compareAlphaNumericVersions(
+            return compareAlphaNumericVersions(
                 preReleaseVersion,
                 other.getPreReleaseVersion()
             );
         }
-        return result;
     }
     
     private int compareBuildVersions(Version other) {
-        int result;
-        if (buildVersion == null && 
-                other.getBuildVersion()== null) {
-            result = 0;
-        } else if (buildVersion == null || 
-                other.getBuildVersion()== null) {
-            result = buildVersion == null ? -1 : 1;
+        if (buildVersion == null ^ other.getBuildVersion() == null) {
+            return buildVersion == null ? -1 : 1;
         } else {
-            result = compareAlphaNumericVersions(
+            return compareAlphaNumericVersions(
                 buildVersion,
                 other.getBuildVersion()
             );    
         }
-        return result;
     }
     
     private int compareAlphaNumericVersions(String thisOp, String otherOp) {
+        if (thisOp == null && otherOp == null) {
+            return 0;
+        }
         String[] thisIdents  = thisOp.split("\\.");
         String[] otherIdents = otherOp.split("\\.");
         

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jsemver.git



More information about the pkg-java-commits mailing list