jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-313

Unnecessary copy of elements

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed 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

Task - A task that needs to be done. XSTR-317 XStream 1.2 release coordination.

  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Joerg Schaible added a comment - 24/May/06 11:15 AM

Done. Thanks for reporting.

Show
Joerg Schaible added a comment - 24/May/06 11:15 AM Done. Thanks for reporting.
Hide
Permalink
Guilherme Silveira added a comment - 31/Jul/06 5:23 PM

moving to 1.2

Show
Guilherme Silveira added a comment - 31/Jul/06 5:23 PM moving to 1.2

People

  • Assignee:
    Unassigned
    Reporter:
    Elifarley Callado Coelho
Vote (0)
Watch (1)

Dates

  • Created:
    08/May/06 6:22 AM
    Updated:
    31/Jul/06 5:28 PM
    Resolved:
    31/Jul/06 5:28 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.