Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2001-08-27 15:44:09 +0000
committerJohn Arthorne2001-08-27 15:44:09 +0000
commit0368cb6bb034b0d366f8bed2c71181676393b07a (patch)
treebd9b969cf48a20c35b810da7606509ef0d4fe872
parent20eeb4eb079666f866fd35a0d240def643712069 (diff)
downloadeclipse.platform.resources-unlabeled-1.4.6.tar.gz
eclipse.platform.resources-unlabeled-1.4.6.tar.xz
eclipse.platform.resources-unlabeled-1.4.6.zip
More optimizations, see summary in 1GHFO1Munlabeled-1.4.6
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java
index afa00741f..587164e0b 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java
@@ -5,12 +5,21 @@ package org.eclipse.core.internal.resources;
* All Rights Reserved.
*/
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import java.util.HashMap;
+
import org.eclipse.core.internal.utils.Assert;
import org.eclipse.core.internal.utils.Policy;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
public class WorkspaceRoot extends Container implements IWorkspaceRoot {
+ /**
+ * As an optimization, we store a table of project handles
+ * that have been requested from this root. This maps project
+ * name strings to project handles.
+ */
+ private HashMap projectTable = new HashMap(10);
+
protected WorkspaceRoot(IPath path, Workspace container) {
super(path, container);
Assert.isTrue(path.equals(Path.ROOT));
@@ -105,10 +114,16 @@ public IProject getProject() {
* @see IResource#getProject
*/
public IProject getProject(String name) {
- IPath path = Path.ROOT.append(name);
- String message = "resources.projectPath";
- Assert.isLegal(path.segmentCount() == ICoreConstants.PROJECT_SEGMENT_LENGTH, message);
- return new Project(path, workspace);
+ //first check our project cache
+ Project result = (Project)projectTable.get(name);
+ if (result == null) {
+ IPath path = Path.ROOT.append(name);
+ String message = "resources.projectPath";
+ Assert.isLegal(path.segmentCount() == ICoreConstants.PROJECT_SEGMENT_LENGTH, message);
+ result = new Project(path, workspace);
+ projectTable.put(name, result);
+ }
+ return result;
}
/**
* @see IResource#getProjectRelativePath

Back to the top