JDK-4112544 : RFE for component tracking in Container.java
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1998-02-16
  • Updated: 2020-01-13
  • Resolved: 2020-01-13
Related Reports
Duplicate :  
Relates :  
Description

Name: diC59631			Date: 02/16/98


The following code (share/java/java/awt/Container.java) seems to be doing a lot
of arraycopy and reallocation of arrays by doubling the arraysize.
I wonder why it cant be implemented as component list, where
- no need to allocate such big array by doubling the arraysize
- insertion of components becomes easier
- no array copies.
- Specially, in the case of embedded platforms, it would use more memory and
  may be would be less efficient.
For ex. if I consider 50 components to be inserted in some random order, it would
- reallocate arrays 5 times
- Garbage collection a no. of times &
- arraycopy more than 50 times.
This delay just multiplies

            /* Add component to list; allocate new array if necessary. */
            if (ncomponents == component.length) {
                Component newcomponents[] = new Component[ncomponents * 2];
                System.arraycopy(component, 0, newcomponents, 0, ncomponents);
                component = newcomponents;
            }
            if (index == -1 || index == ncomponents) {
                component[ncomponents++] = comp;
            } else {
                System.arraycopy(component, index, component,
                                 index + 1, ncomponents - index);
                component[index] = comp;
                ncomponents++;
            }
(Review ID: 25082)
======================================================================

Comments
WORK AROUND Name: diC59631 Date: 02/16/98 Implementing as Component link list/tree ======================================================================
22-09-2004

EVALUATION I could consider this performance-related, and am assigning to echawkes brent.christian@eng 1999-12-13 Committing to Tiger. A list structure may make sense here, but a tree probably does not. See Comments. eric.hawkes@eng 2000-02-07 The performance team does profiling. If this comes up as a performance bottleneck, we'll look into it. Decommitting for now. ###@###.### 2003-02-28
07-02-2000