浏览代码

ZOOKEEPER-3685: Use JDK Arrays Equals for Jute

Author: David Mollitor <dmollitor@apache.org>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Norbert Kalmar <nkalmar@apache.org>

Closes #1213 from belugabehr/ZOOKEEPER-3685
David Mollitor 5 年之前
父节点
当前提交
ed251d4373

+ 0 - 26
zookeeper-jute/src/main/java/org/apache/jute/Utils.java

@@ -30,32 +30,6 @@ public class Utils {
         super();
         super();
     }
     }
 
 
-    /**
-     * equals function that actually compares two buffers.
-     *
-     * @param onearray First buffer
-     * @param twoarray Second buffer
-     * @return true if one and two contain exactly the same content, else false.
-     */
-    public static boolean bufEquals(byte[] onearray, byte[] twoarray) {
-        if (onearray == twoarray) {
-            return true;
-        }
-
-        boolean ret = (onearray.length == twoarray.length);
-
-        if (!ret) {
-            return ret;
-        }
-
-        for (int idx = 0; idx < onearray.length; idx++) {
-            if (onearray[idx] != twoarray[idx]) {
-                return false;
-            }
-        }
-        return true;
-    }
-
     public static int compareBytes(byte[] b1, int off1, int len1, byte[] b2, int off2, int len2) {
     public static int compareBytes(byte[] b1, int off1, int len1, byte[] b2, int off2, int len2) {
         int i;
         int i;
         for (i = 0; i < len1 && i < len2; i++) {
         for (i = 0; i < len1 && i < len2; i++) {

+ 1 - 1
zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java

@@ -75,7 +75,7 @@ public class JBuffer extends JCompType {
     }
     }
 
 
     public String genJavaEquals(String fname, String peer) {
     public String genJavaEquals(String fname, String peer) {
-        return "    ret = org.apache.jute.Utils.bufEquals(" + fname + "," + peer + ");\n";
+        return "    ret = java.util.Arrays.equals(" + fname + "," + peer + ");\n";
     }
     }
 
 
     public String genJavaHashCode(String fname) {
     public String genJavaHashCode(String fname) {