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
* Removes all of the items from the underlying widget.
     */
    protected abstract void listRemoveAll();
    /**
     * Removes the item from the underlying widget at the given
     * zero-relative index.
     * 
     * @param index the index for the item
     */
    protected abstract void listRemove(int index);
    /**
     * Selects the items at the given zero-relative indices in the underlying widget.
     * The current selection is cleared before the new items are selected.
     * <p>
     * Indices that are out of range and duplicate indices are ignored.
     * If the receiver is single-select and multiple indices are specified,
     * then all indices are ignored.
     *
     * @param ixs the indices of the items to select
     */
    protected abstract void listSetSelection(int[] ixs);
    /**
     * Shows the selection.  If the selection is already showing in the receiver,
     * this method simply returns.  Otherwise, the items are scrolled until
     * the selection is visible.
     */
    protected abstract void listShowSelection();
    /**
     * Deselects all selected items in the underlying widget.
     */