Bug 139700 Long delay on package explorer selection changes in large workspace
Build: Eclipse 3.2 RC2 I created a workspace with every callisto project added (600 projects). Clicking around in the Navigator, I found a long delay responding to selection changes (2-3 seconds on a dual 3 Ghz machine with 1024 MB RAM). The culprit is CloseUnrelatedProjectsAction.getSelectedResources. The algorithm it uses for computing the set of "unrelated projects" is O(N^3) on the number of projects in the worst case (the worst case being where all N projects are tightly related to each other, as in the Callisto project case). This should be fixed for 3.2, either by improving the algorithm, or not updating the set of unrelated projects when the selection changes. It currently does this in order to update the enablement of the action (disabling the action when there are no open unrelated projects).
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/CloseUnrelatedProjectsAction.java
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CloseResourceAction;
import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
/**
 * This action closes all projects that are unrelated to the selected projects. A
 * project is unrelated if it is not directly or transitively referenced by one 
 * of the selected projects, and does not directly or transitively reference
 * one of the selected projects.
 * <p>
 * This class may be instantiated; it is not intended to be subclassed.
 * </p>
 * 
 * @see IDEActionFactory#CLOSE_UNRELATED_PROJECTS
 * @since 3.2
 */
public class CloseUnrelatedProjectsAction extends CloseResourceAction {