Bug 70856 [Viewers] ComboViewer internalRefresh is slow
When you call ComboViewer internalRefresh (via StructuredViewer.refresh), the viewer clears the model, gets the list of items from the data model and walks through them one by one, adding them to the combo and the element map: ILabelProvider labelProvider= (ILabelProvider) getLabelProvider(); for (int i= 0; i < children.length; i++) { Object el = children[i]; listAdd(labelProvider.getText(el), i); listMap.add(el); mapElement(el, list); // must map it, since findItem only looks in map, if enabled } However, this is a slow process because listAdd() calls combo.add(), which copies over the current list and adds one item to it. So in my list of 376 items, 376 new Arrays are created, weahc one larger than the last, and 376 arrayCopy's are done and combo.setItems() is callled 376 times, and from my profiling, it looks like a lot of time is spent in setItems. Would it be better to do: ILabelProvider labelProvider= (ILabelProvider) getLabelProvider(); String[] items = new String[children.length]; for (int i= 0; i < children.length; i++) { Object el = children[i]; //listAdd(labelProvider.getText(el), i); item[i] = labelProvider.getText(el); listMap.add(el); mapElement(el, list); // must map it, since findItem only looks in map, if enabled } listSetItems(items); which will call combo.setItems() only once? I have not been able to test this, because of the listMap variable referred to above is private and I can't subclass ComboViewer anyway because it is final.
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractListViewer.java
* Sets the text of the item at the given index in the underlying widget.
     * 
     * @param index index to modify
     * @param string new text
     */
    protected abstract void listSetItem(int index, String string);
    /**
     * Returns the zero-relative indices of the items which are currently
     * selected in the underlying widget.  The array is empty if no items are selected.
     * <p>
     * Note: This is not the actual structure used by the receiver
     * to maintain its selection, so modifying the array will
     * not affect the receiver. 
     * </p>
     * @return the array of indices of the selected items
     */
    protected abstract int[] listGetSelectionIndices();
    /**
     * Returns the number of items contained in the underlying widget.
     *
     * @return the number of items
     */
    protected abstract int listGetItemCount();
    /**
     * Sets the underlying widget's items to be the given array of items.
     *
     * @param labels the array of label text
     */
    protected abstract void listSetItems(String[] labels);
    /**