From c24f62f57922da62b47d9da3e59cc80328408242 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 12 Dec 2014 15:16:22 +0000
Subject: [PATCH] Cleanup work before committing a new version of the pluggable storage backend.

---
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java |   51 +++++++++++++++++++++------------------------------
 1 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java
index 74c8a16..737c3e7 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VLVKeyComparator.java
@@ -67,7 +67,7 @@
   private boolean[] ascending;
 
   /**
-   * Construst a new VLV Key Comparator object.
+   * Construct a new VLV Key Comparator object.
    *
    * @param orderingRules The array of ordering rules to use when comparing
    *                      the decoded values in the key.
@@ -219,20 +219,7 @@
     {
       long b1ID = JebFormat.toLong(b1, b1Pos, b1Pos + 8);
       long b2ID = JebFormat.toLong(b2, b2Pos, b2Pos + 8);
-
-      long idDifference = (b1ID - b2ID);
-      if (idDifference < 0)
-      {
-        return -1;
-      }
-      else if (idDifference > 0)
-      {
-        return 1;
-      }
-      else
-      {
-        return 0;
-      }
+      return compare(b1ID, b2ID);
     }
 
     // If we've gotten here, then we can't tell the difference between the sets
@@ -248,7 +235,7 @@
    *
    * If the given attribute values array does not contain all the values in the
    * sort order, any missing values will be considered as a unknown or
-   * wildcard value instead of a nonexistant value. When comparing partial
+   * wildcard value instead of a non existent value. When comparing partial
    * information, only values available in both the values set and the
    * given values will be used to determine the ordering. If all available
    * information is the same, 0 will be returned.
@@ -325,20 +312,7 @@
     {
       // If we've gotten here, then we can't tell a difference between the sets
       // of values, so sort based on entry ID.
-
-      long idDifference = (set.getEntryIDs()[index] - entryID);
-      if (idDifference < 0)
-      {
-        return -1;
-      }
-      else if (idDifference > 0)
-      {
-        return 1;
-      }
-      else
-      {
-        return 0;
-      }
+      return compare(set.getEntryIDs()[index], entryID);
     }
 
     // If we've gotten here, then we can't tell the difference between the sets
@@ -346,6 +320,23 @@
     return 0;
   }
 
+  private int compare(long l1, long l2)
+  {
+    final long difference = l1 - l2;
+    if (difference < 0)
+    {
+      return -1;
+    }
+    else if (difference > 0)
+    {
+      return 1;
+    }
+    else
+    {
+      return 0;
+    }
+  }
+
   /** {@inheritDoc} */
   @Override
   public void initialize(ClassLoader loader)

--
Gitblit v1.10.0