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
/*******************************************************************************
 * Copyright (c) 2004, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Tom Schindl <tom.schindl@bestsolution.at> - concept of ViewerRow,
 *                                                 refactoring (bug 153993), bug 167323, 191468, 205419
 *     Matthew Hall - bug 221988
 *******************************************************************************/
package org.eclipse.jface.viewers;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.jface.util.Policy;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.TreeEvent;
import org.eclipse.swt.events.TreeListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Item;