-
Enhancement
-
Resolution: Not an Issue
-
P4
-
21, 22
The else-if and else clauses in method ArraysSupport::hugeLength could be simplified by Math::max.
diff --git a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
index 61be28519fc..09fb974c254 100644
--- a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
+++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
@@ -751,10 +751,8 @@ private static int hugeLength(int oldLength, int minGrowth) {
if (minLength < 0) { // overflow
throw new OutOfMemoryError(
"Required array length " + oldLength + " + " + minGrowth + " is too large");
- } else if (minLength <= SOFT_MAX_ARRAY_LENGTH) {
- return SOFT_MAX_ARRAY_LENGTH;
- } else {
- return minLength;
+ } else {
+ return Math.max(minLength, SOFT_MAX_ARRAY_LENGTH);
}
}
diff --git a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
index 61be28519fc..09fb974c254 100644
--- a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
+++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
@@ -751,10 +751,8 @@ private static int hugeLength(int oldLength, int minGrowth) {
if (minLength < 0) { // overflow
throw new OutOfMemoryError(
"Required array length " + oldLength + " + " + minGrowth + " is too large");
- } else if (minLength <= SOFT_MAX_ARRAY_LENGTH) {
- return SOFT_MAX_ARRAY_LENGTH;
- } else {
- return minLength;
+ } else {
+ return Math.max(minLength, SOFT_MAX_ARRAY_LENGTH);
}
}
- links to
-
Review openjdk/jdk/17043