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

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


The following commit(s) were added to refs/heads/master by this push:
     new ed251d4  ZOOKEEPER-3685: Use JDK Arrays Equals for Jute
ed251d4 is described below

commit ed251d43733996d72b9c57b7ba9822f49d25b4e6
Author: David Mollitor <[email protected]>
AuthorDate: Wed Feb 12 15:48:01 2020 +0100

    ZOOKEEPER-3685: Use JDK Arrays Equals for Jute
    
    Author: David Mollitor <[email protected]>
    
    Reviewers: Enrico Olivelli <[email protected]>, Norbert Kalmar 
<[email protected]>
    
    Closes #1213 from belugabehr/ZOOKEEPER-3685
---
 .../src/main/java/org/apache/jute/Utils.java       | 26 ----------------------
 .../java/org/apache/jute/compiler/JBuffer.java     |  2 +-
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/zookeeper-jute/src/main/java/org/apache/jute/Utils.java 
b/zookeeper-jute/src/main/java/org/apache/jute/Utils.java
index cf14f67..7364e40 100644
--- a/zookeeper-jute/src/main/java/org/apache/jute/Utils.java
+++ b/zookeeper-jute/src/main/java/org/apache/jute/Utils.java
@@ -30,32 +30,6 @@ public class Utils {
         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) {
         int i;
         for (i = 0; i < len1 && i < len2; i++) {
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java 
b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java
index 92274ed..6e3a956 100644
--- a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java
+++ b/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) {
-        return "    ret = org.apache.jute.Utils.bufEquals(" + fname + "," + 
peer + ");\n";
+        return "    ret = java.util.Arrays.equals(" + fname + "," + peer + 
");\n";
     }
 
     public String genJavaHashCode(String fname) {

Reply via email to