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

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

commit 75d1d8736d1bb8d1b43eeb228b1df3ca352ede57
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 a234da2f0c..32eaa33e5b 100644
--- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
+++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
@@ -160,23 +160,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
@@ -243,10 +226,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