History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-313
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Elifarley Callado Coelho
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XStream

Unnecessary copy of elements

Created: 08/May/06 06:22 AM   Updated: 31/Jul/06 05:28 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2

Issue Links:
dependent
 


 Description  « Hide
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.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 24/May/06 11:15 AM
Done. Thanks for reporting.

Guilherme Silveira - 31/Jul/06 05:23 PM
moving to 1.2