Bug 253773 [Viewers] Collapsed expandable nodes in a TreeViewer are needlessly expensive
In the Expressions view, the debug platform TreeViewer needlessly causes the model to be queried for all children of collapsed expandable items. This can have serious performance repercussions. This can be easily seen in a CDT gdb debug session. Create a simple C project with the following main(). Launch a debug session and add 'arr1' and 'arr2' in the Expressions view. Don't expand them. Simple step through the loop. Every step takes about 3-4 seconds on a relatively fast machine. Close the Expressions view, stepping becomes instantaneous. int main() { int arr1[100]; int arr2[100]; while (1) { int i = 1; i++; } return arr1[0] + arr2[0]; }
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
/**
 * A concrete viewer based on an SWT <code>Tree</code> control.
 * <p>
 * This class is not intended to be subclassed outside the viewer framework. It
 * is designed to be instantiated with a pre-existing SWT tree control and
 * configured with a domain-specific content provider, label provider, element
 * filter (optional), and element sorter (optional).
 * </p>
 * <p>
 * Content providers for tree viewers must implement either the
 * {@link ITreeContentProvider} interface, (as of 3.2) the
 * {@link ILazyTreeContentProvider} interface, or (as of 3.3) the
 * {@link ILazyTreePathContentProvider}. If the content provider is an
 * <code>ILazyTreeContentProvider</code> or an
 * <code>ILazyTreePathContentProvider</code>, the underlying Tree must be
 * created using the {@link SWT#VIRTUAL} style bit, the tree viewer will not
 * support sorting or filtering, and hash lookup must be enabled by calling
 * {@link #setUseHashlookup(boolean)}.
 * </p>
 * <p>
 * Users setting up an editable tree with more than 1 column <b>have</b> to pass the
 * SWT.FULL_SELECTION style bit
 * </p>
 * @noextend This class is not intended to be subclassed by clients.
 */
public class TreeViewer extends AbstractTreeViewer {