The method 'resizeStack' from classes 'FastStack' and 'ClassStack' call 'System.arrayCopy' using a length which sometimes is unnecessarily too big.
I suggest you change this method:
private void resizeStack(int newCapacity) {
Object[] newStack = new Object[newCapacity];
System.arraycopy(stack, 0, newStack, 0, Math.min(stack.length, newCapacity));
stack = newStack;
}
to read as follows:
private void resizeStack(int newCapacity) {
Object[] newStack = new Object[newCapacity];
System.arraycopy(stack, 0, newStack, 0, Math.min(pointer, newCapacity));
stack = newStack;
}
Since pointer <= stack.length and the elements that come after stack[pointer - 1] will never be read anyway.