Details
-
Type: Improvement
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.2
-
Component/s: None
-
Labels:None
Description
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.
Issue Links
- is depended upon by
-
XSTR-317 XStream 1.2 release coordination.
Done. Thanks for reporting.