Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8076419

Path2D copy constructors and clone method propagate size of arrays from source path

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
      2d
    • Resolved In Build:
      b61

      Backports

        Description

        The copy constructors and clone method on the Path2D classes all set the internal arrays for the new objects to the size of the arrays for the source objects. Since the copies are typically done to save a path aside, or to return an "effectively immutable" answer from a method, the added room for growth is not needed - only the existing path segments need to be saved.

        The waste is normally minor, but for a program that uses a single scratch path to accumulate paths of varying sizes and then clones or copies it as a return value, over time that scratch path may grow large, but the subsequent results it is calculating may be much smaller. The issue is that as the scratch path grows, so does the size of its result values - regardless of the complexity of the subsequent results.

        The copy constructors should only create new arrays in the new paths large enough for the path segments already stored in the source path.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                flar Jim Graham
                Reporter:
                flar Jim Graham
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: