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

          People

          • Assignee:
            Unassigned
            Reporter:
            Elifarley Callado Coelho
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: