JDK-6436314 : Vector could be created with appropriate size in DefaultComboBoxModel
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6,7,8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-06-08
  • Updated: 2014-10-10
  • Resolved: 2013-05-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40Fixed 8 b94Fixed
Description
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.

Comments
EVALUATION Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=13774
21-06-2006