This is an automated email from the ASF dual-hosted git repository.
lihan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new f459e9686e Replace with JDK 1.8 Integer::compareUnsigned(int, int).
f459e9686e is described below
commit f459e9686ebe2703379cdf4f182010f94f312b62
Author: lihan <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]