You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by jm...@apache.org on 2020/04/27 18:39:50 UTC

[accumulo] branch master updated: Use Long.compare() to compare longs. (#1600)

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

jmark99 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new c8fe3d2  Use Long.compare() to compare longs. (#1600)
c8fe3d2 is described below

commit c8fe3d23028cb81a08d8eb9537aa17d4b9072d05
Author: Mark Owens <jm...@apache.org>
AuthorDate: Mon Apr 27 14:39:41 2020 -0400

    Use Long.compare() to compare longs. (#1600)
    
    Make use of the Long.compare() method, introduced in JDK 7, to compare longs instead of more verbose constructs.
---
 core/src/main/java/org/apache/accumulo/core/data/Key.java         | 7 +------
 .../src/main/java/org/apache/accumulo/tserver/FileManager.java    | 8 +-------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/data/Key.java b/core/src/main/java/org/apache/accumulo/core/data/Key.java
index 6b21da6..ee07f53 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Key.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Key.java
@@ -998,12 +998,7 @@ public class Key implements WritableComparable<Key>, Cloneable {
       return result;
 
     // check for matching timestamp
-    if (timestamp < other.timestamp)
-      result = 1;
-    else if (timestamp > other.timestamp)
-      result = -1;
-    else
-      result = 0;
+    result = Long.compare(other.timestamp, timestamp);
 
     if (result != 0 || part.equals(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME))
       return result;
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java
index 868408f..831fca7 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/FileManager.java
@@ -82,13 +82,7 @@ public class FileManager {
 
     @Override
     public int compareTo(OpenReader o) {
-      if (releaseTime < o.releaseTime) {
-        return -1;
-      } else if (releaseTime > o.releaseTime) {
-        return 1;
-      } else {
-        return 0;
-      }
+      return Long.compare(releaseTime, o.releaseTime);
     }
 
     @Override