Skip to content

Commit 396ed88

Browse files
lu-pintomacfarla
andcommitted
Rename SOFT_MAX_ARRAY_LENGTH to MAX_ARRAY_LENGTH
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
1 parent 8104be6 commit 396ed88

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

evm/src/main/java/org/hyperledger/besu/evm/internal/FlexStack.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public class FlexStack<T> {
4040

4141
/**
4242
* Soft limit imposed for growing arrays. JVMs do not allow to allocate arrays above certain
43-
* length and you will get the following exception if trying to do so:
43+
* length, and you will get the following exception if trying to do so:
4444
*
4545
* <p>java.lang.OutOfMemoryError: Requested array size exceeds VM limit
4646
*
4747
* <p>Therefore the maxSize of any stack is capped to this value. This max value is not arbitrary
4848
* and was taken from OpenJDK.
4949
*/
50-
private static final int SOFT_MAX_ARRAY_LENGTH = Integer.MAX_VALUE - 8;
50+
private static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - 8;
5151

5252
private T[] entries;
5353

@@ -65,7 +65,7 @@ public class FlexStack<T> {
6565
@SuppressWarnings("unchecked")
6666
public FlexStack(final int maxSize, final Class<T> klass) {
6767
checkArgument(maxSize > 0, "max size must be positive");
68-
checkArgument(maxSize <= SOFT_MAX_ARRAY_LENGTH, "max size is too large");
68+
checkArgument(maxSize <= MAX_ARRAY_LENGTH, "max size is too large");
6969

7070
int initialSize = (int) Math.round(maxSize * INITIAL_SIZE_COEFICIENT) + 1;
7171
this.currentCapacity = Math.min(initialSize, maxSize);
@@ -190,7 +190,7 @@ public void push(final T operand) {
190190

191191
private int newLength(final int oldCapacity, final int prefGrowth) {
192192
final int growth = Math.max(1, prefGrowth);
193-
if (SOFT_MAX_ARRAY_LENGTH - growth < oldCapacity) {
193+
if (MAX_ARRAY_LENGTH - growth < oldCapacity) {
194194
return maxSize;
195195
}
196196
return Math.min(oldCapacity + growth, maxSize);

0 commit comments

Comments
 (0)