1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

cache the values in the info for speed

This commit is contained in:
Alain Magloire 2004-04-07 04:06:02 +00:00
parent b9ee10a300
commit 9d1f92adf4
5 changed files with 47 additions and 17 deletions

View file

@ -1,3 +1,12 @@
2004-04-06 Alain Magloire
Cache the values in the info.
* model/org/eclipse/cdt/internal/core/model/CElement.java
* model/org/eclipse/cdt/internal/core/model/CProject.java
* model/org/eclipse/cdt/internal/core/model/CProjectInfo.java
* model/org/eclipse/cdt//core/model/CoreModel.java
2004-04-06 Alain Magloire
Patch from Chris Wiebe.

View file

@ -401,7 +401,7 @@ public class CoreModel {
* @return IIncludeEntry
*/
public static IIncludeEntry newIncludeEntry(IPath includePath) {
return newIncludeEntry(null, includePath, false);
return newIncludeEntry(null, includePath);
}
/**
@ -430,7 +430,7 @@ public class CoreModel {
* @return IIncludeEntry
*/
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude) {
return newIncludeEntry(resourcePath, includePath, null, isSystemInclude, IncludeEntry.NO_EXCLUSION_PATTERNS);
return newIncludeEntry(resourcePath, includePath, isSystemInclude, IncludeEntry.NO_EXCLUSION_PATTERNS);
}
/**

View file

@ -302,18 +302,6 @@ public abstract class CElement extends PlatformObject implements ICElement {
* @throws CModelException
*/
public void close() throws CModelException {
//Object info = CModelManager.getDefault().peekAtInfo(this);
//if (info != null) {
// if (this instanceof IParent) {
// ICElement[] children = ((CElementInfo) info).getChildren();
// for (int i = 0, size = children.length; i < size; ++i) {
// CElement child = (CElement) children[i];
// child.close();
// }
// }
// closing(info);
// CModelManager.getDefault().removeInfo(this);
//}
CModelManager.getDefault().releaseCElement(this);
}

View file

@ -435,14 +435,41 @@ public class CProject extends Openable implements ICProject {
* @throws CModelException
*/
public ISourceRoot[] getAllSourceRoots() throws CModelException {
return computeSourceRoots();
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
ISourceRoot[] roots = null;
if (pinfo != null) {
if (pinfo.sourceRoots != null) {
roots = pinfo.sourceRoots;
} else {
roots = pinfo.sourceRoots = computeSourceRoots();
}
} else {
roots = computeSourceRoots();
}
return roots;
}
public IOutputEntry[] getOutputEntries() throws CModelException {
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
IOutputEntry[] outs = null;
if (pinfo != null) {
if (pinfo.outputEntries != null) {
outs = pinfo.outputEntries;
} else {
IPathEntry[] entries = getResolvedPathEntries();
outs = pinfo.outputEntries = getOutputEntries(entries);
}
} else {
IPathEntry[] entries = getResolvedPathEntries();
outs = getOutputEntries(entries);
}
return outs;
}
/**
*
*/
public IOutputEntry[] getOutputEntries() throws CModelException {
IPathEntry[] entries = getResolvedPathEntries();
public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException {
ArrayList list = new ArrayList(entries.length);
for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == IPathEntry .CDT_OUTPUT) {

View file

@ -13,6 +13,7 @@ import org.eclipse.cdt.core.model.IBinaryContainer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.core.model.ILibraryReference;
import org.eclipse.cdt.core.model.IOutputEntry;
import org.eclipse.cdt.core.model.ISourceRoot;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
@ -29,6 +30,8 @@ class CProjectInfo extends OpenableInfo {
ArchiveContainer vLib;
ILibraryReference[] libReferences;
IIncludeReference[] incReferences;
ISourceRoot[] sourceRoots;
IOutputEntry[] outputEntries;
Object[] nonCResources = null;
@ -146,6 +149,9 @@ class CProjectInfo extends OpenableInfo {
}
}
}
sourceRoots = null;
outputEntries = null;
setNonCResources(null);
}
}