From d98954d29a00b776a7552a849405b30aabce404e Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 26 Jan 2012 12:51:29 +0000
Subject: [PATCH] Minor code cleanup.

---
 opends/src/server/org/opends/server/util/StaticUtils.java                                     |   45 ----------------------
 opends/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java |   37 +-----------------
 2 files changed, 4 insertions(+), 78 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java b/opends/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
index 5949680..eb9a014 100644
--- a/opends/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
+++ b/opends/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRule.java
@@ -36,6 +36,7 @@
 import org.opends.server.api.AbstractMatchingRule;
 import org.opends.server.api.OrderingMatchingRule;
 import org.opends.server.types.*;
+import org.opends.server.util.StaticUtils;
 
 /**
  * Used to establish an order between historical information and index them.
@@ -157,43 +158,11 @@
   }
 
   /**
-   * Compares two normalized representation of historical information.
-   * @param b1 first value to compare
-   * @param b2 second value to compare
-   * @return 0, -1 or 1 depending on relative positions
+   * {@inheritDoc}
    */
   public int compare(byte[] b1, byte[] b2)
   {
-    int minLength = Math.min(b1.length, b2.length);
-
-    for (int i=0; i < minLength; i++)
-    {
-      if (b1[i] == b2[i])
-      {
-        continue;
-      }
-      else if (b1[i] < b2[i])
-      {
-        return -1;
-      }
-      else if (b1[i] > b2[i])
-      {
-        return 1;
-      }
-    }
-
-    if (b1.length == b2.length)
-    {
-      return 0;
-    }
-    else if (b1.length < b2.length)
-    {
-      return -1;
-    }
-    else
-    {
-      return 1;
-    }
+    return StaticUtils.compare(b1, b2);
   }
 
 }
diff --git a/opends/src/server/org/opends/server/util/StaticUtils.java b/opends/src/server/org/opends/server/util/StaticUtils.java
index 87d6caf..e09a347 100644
--- a/opends/src/server/org/opends/server/util/StaticUtils.java
+++ b/opends/src/server/org/opends/server/util/StaticUtils.java
@@ -23,7 +23,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011 ForgeRock AS
+ *      Portions Copyright 2011-2012 ForgeRock AS
  */
 package org.opends.server.util;
 
@@ -1443,49 +1443,6 @@
 
 
   /**
-   * Compare two byte arrays for order. Returns a negative integer,
-   * zero, or a positive integer as the first argument is less than,
-   * equal to, or greater than the second.
-   *
-   * @param a
-   *          The first byte array to be compared.
-   * @param a2
-   *          The second byte array to be compared.
-   * @return Returns a negative integer, zero, or a positive integer
-   *         if the first byte array is less than, equal to, or greater
-   *         than the second.
-   */
-  @Deprecated
-  public static int compare(ByteSequence a, ByteSequence a2) {
-    if (a == a2) {
-      return 0;
-    }
-
-    if (a == null) {
-      return -1;
-    }
-
-    if (a2 == null) {
-      return 1;
-    }
-
-    int minLength = Math.min(a.length(), a2.length());
-    for (int i = 0; i < minLength; i++) {
-      if (a.byteAt(i) != a2.byteAt(i)) {
-        if (a.byteAt(i) < a2.byteAt(i)) {
-          return -1;
-        } else if (a.byteAt(i) > a2.byteAt(i)) {
-          return 1;
-        }
-      }
-    }
-
-    return (a.length() - a2.length());
-  }
-
-
-
-  /**
    * Indicates whether the two array lists are equal. They will be
    * considered equal if they have the same number of elements, and
    * the corresponding elements between them are equal (in the same

--
Gitblit v1.10.0