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

lihan pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 008abc31d4e68ef5b0f9bacd9b65b92d8f2a77d0
Author: lihan <li...@apache.org>
AuthorDate: Sun Feb 26 15:11:17 2023 +0800

    Replace with JDK 1.8 Integer::compareUnsigned(int, int).
---
 .../apache/tomcat/util/codec/binary/BaseNCodec.java | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java 
b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
index 0bfcf7312a..3575c992a8 100644
--- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
+++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
@@ -148,23 +148,6 @@ public abstract class BaseNCodec {
      */
     static final byte[] CHUNK_SEPARATOR = {'\r', '\n'};
 
-    /**
-     * Compares two {@code int} values numerically treating the values
-     * as unsigned. Taken from JDK 1.8.
-     *
-     * <p>TODO: Replace with JDK 1.8 Integer::compareUnsigned(int, int).</p>
-     *
-     * @param  x the first {@code int} to compare
-     * @param  y the second {@code int} to compare
-     * @return the value {@code 0} if {@code x == y}; a value less
-     *         than {@code 0} if {@code x < y} as unsigned values; and
-     *         a value greater than {@code 0} if {@code x > y} as
-     *         unsigned values
-     */
-    private static int compareUnsigned(final int x, final int y) {
-        return Integer.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE);
-    }
-
     /**
      * Create a positive capacity at least as large the minimum required 
capacity.
      * If the minimum capacity is negative then this throws an 
OutOfMemoryError as no array
@@ -201,10 +184,10 @@ public abstract class BaseNCodec {
         // Overflow-conscious code treats the min and new capacity as unsigned.
         final int oldCapacity = context.buffer.length;
         int newCapacity = oldCapacity * DEFAULT_BUFFER_RESIZE_FACTOR;
-        if (compareUnsigned(newCapacity, minCapacity) < 0) {
+        if (Integer.compareUnsigned(newCapacity, minCapacity) < 0) {
             newCapacity = minCapacity;
         }
-        if (compareUnsigned(newCapacity, MAX_BUFFER_SIZE) > 0) {
+        if (Integer.compareUnsigned(newCapacity, MAX_BUFFER_SIZE) > 0) {
             newCapacity = createPositiveCapacity(minCapacity);
         }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to