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

Vector could be created with appropriate size in DefaultComboBoxModel

XMLWordPrintable

    • b94
    • generic
    • generic

        src/share/classes/javax/swing/DefaultComboBoxModel.java:51: public DefaultComboBoxModel(final Object items[]) {
            src/share/classes/javax/swing/DefaultComboBoxModel.java:52: objects = new Vector();
            src/share/classes/javax/swing/DefaultComboBoxModel.java:53: objects.ensureCapacity( items.length );

        creates a default-sized Vector and then resizes it. That probably drops the default-sized backing array on the floor and allocates a new one. It would be more efficient to create the Vector with the appropriate size. I don't know what the average size of the items array is to the DefaultComboBoxModel constructor. If that array is typically small, then maybe this isn't a problem.

              vkarnauk Vladislav Karnaukhov
              pbk Peter Kessler
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: