mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CModelBuilder and scalability problems
This commit is contained in:
parent
3dc5e212e0
commit
09739d577e
9 changed files with 64 additions and 18 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-04-16 Hoda Amer
|
||||||
|
-CModelBuilder and scalability problems: Starting children list with initial size = 0
|
||||||
|
Now 25,000 element Translation unit takes 450 ms in CModelBuilder.
|
||||||
|
-Also removed class Parent implemention interface IParent as only elements that
|
||||||
|
could really be parents should implement it.
|
||||||
|
|
||||||
2004-04-15 Alain Magloire
|
2004-04-15 Alain Magloire
|
||||||
|
|
||||||
Archive/BinaryContainer was not cleaned up.
|
Archive/BinaryContainer was not cleaned up.
|
||||||
|
|
|
@ -35,5 +35,19 @@ public interface IParent {
|
||||||
*/
|
*/
|
||||||
boolean hasChildren();
|
boolean hasChildren();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a child to the current element.
|
||||||
|
* Implementations override this method to support children
|
||||||
|
*/
|
||||||
|
void addChild(ICElement member);
|
||||||
|
/**
|
||||||
|
* Removes a child from the current element children list.
|
||||||
|
* @param member
|
||||||
|
*/
|
||||||
|
void removeChild(ICElement member);
|
||||||
|
/**
|
||||||
|
* Clears the element's children list.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void removeChildren ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
* (c) Copyright IBM Corp. 2000, 2001.
|
||||||
|
@ -24,4 +26,12 @@ public class ArchiveContainerInfo extends OpenableInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.CElementInfo#addChild(org.eclipse.cdt.core.model.ICElement)
|
||||||
|
*/
|
||||||
|
protected void addChild(ICElement child) {
|
||||||
|
if (!includesChild(child)) {
|
||||||
|
super.addChild(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) Copyright IBM Corp. 2000, 2001.
|
* (c) Copyright IBM Corp. 2000, 2001.
|
||||||
|
@ -24,4 +26,12 @@ public class BinaryContainerInfo extends OpenableInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.CElementInfo#addChild(org.eclipse.cdt.core.model.ICElement)
|
||||||
|
*/
|
||||||
|
protected void addChild(ICElement child) {
|
||||||
|
if (!includesChild(child)) {
|
||||||
|
super.addChild(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -398,6 +398,10 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
CElement child = (CElement) children[i];
|
CElement child = (CElement) children[i];
|
||||||
child.removeInfo();
|
child.removeInfo();
|
||||||
}
|
}
|
||||||
|
// we have to remove children here
|
||||||
|
// to clear the children list before
|
||||||
|
// removing the entry from the cache.
|
||||||
|
((CElementInfo)info).removeChildren();
|
||||||
}
|
}
|
||||||
CModelManager.getDefault().removeInfo(this);
|
CModelManager.getDefault().removeInfo(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@ import org.eclipse.core.resources.IResource;
|
||||||
* Subclassed to carry properties for specific kinds of elements.
|
* Subclassed to carry properties for specific kinds of elements.
|
||||||
*/
|
*/
|
||||||
class CElementInfo {
|
class CElementInfo {
|
||||||
|
/**
|
||||||
|
* Shared empty collection used for efficiency.
|
||||||
|
*/
|
||||||
|
static Object[] NO_NON_C_RESOURCES = new Object[] {};
|
||||||
|
|
||||||
|
|
||||||
protected CElement element;
|
protected CElement element;
|
||||||
|
|
||||||
|
@ -25,7 +30,7 @@ class CElementInfo {
|
||||||
* object. This is an empty array if this element has
|
* object. This is an empty array if this element has
|
||||||
* no children.
|
* no children.
|
||||||
*/
|
*/
|
||||||
protected List fChildren;
|
private List fChildren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the structure of this element known
|
* Is the structure of this element known
|
||||||
|
@ -37,7 +42,8 @@ class CElementInfo {
|
||||||
|
|
||||||
protected CElementInfo(CElement element) {
|
protected CElementInfo(CElement element) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
fChildren = new ArrayList();
|
// Array list starts with size = 0
|
||||||
|
fChildren = new ArrayList(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CElement getElement() {
|
protected CElement getElement() {
|
||||||
|
@ -45,9 +51,9 @@ class CElementInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addChild(ICElement child) {
|
protected void addChild(ICElement child) {
|
||||||
if (!fChildren.contains(child)) {
|
// Do not add a check if the child is contained here
|
||||||
fChildren.add(child);
|
// because it causes a performance bottle neck for large files.
|
||||||
}
|
fChildren.add(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ICElement[] getChildren() {
|
protected ICElement[] getChildren() {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class CModelInfo extends OpenableInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return new Object[] {}; // NO_NON_C_RESOURCES
|
return NO_NON_C_RESOURCES;
|
||||||
}
|
}
|
||||||
if (index < length) {
|
if (index < length) {
|
||||||
System.arraycopy(nonCProjects, 0, nonCProjects = new Object[index], 0, index);
|
System.arraycopy(nonCProjects, 0, nonCProjects = new Object[index], 0, index);
|
||||||
|
|
|
@ -9,9 +9,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
|
||||||
|
|
||||||
public abstract class Parent extends CElement implements IParent {
|
public abstract class Parent extends CElement {
|
||||||
|
|
||||||
public Parent (ICElement parent, String name, int type) {
|
public Parent (ICElement parent, String name, int type) {
|
||||||
super (parent, name, type);
|
super (parent, name, type);
|
||||||
|
@ -23,7 +22,7 @@ public abstract class Parent extends CElement implements IParent {
|
||||||
* Adds a child to the current element.
|
* Adds a child to the current element.
|
||||||
* Implementations override this method to support children
|
* Implementations override this method to support children
|
||||||
*/
|
*/
|
||||||
protected void addChild(ICElement member) {
|
public void addChild(ICElement member) {
|
||||||
getElementInfo().addChild(member);
|
getElementInfo().addChild(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,11 +30,11 @@ public abstract class Parent extends CElement implements IParent {
|
||||||
* Removes a child to the current element.
|
* Removes a child to the current element.
|
||||||
* Implementations override this method to support children
|
* Implementations override this method to support children
|
||||||
*/
|
*/
|
||||||
protected void removeChild(ICElement member) {
|
public void removeChild(ICElement member) {
|
||||||
getElementInfo().removeChild(member);
|
getElementInfo().removeChild(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeChildren () {
|
public void removeChildren () {
|
||||||
getElementInfo().removeChildren();
|
getElementInfo().removeChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ public abstract class Parent extends CElement implements IParent {
|
||||||
public ICElement[] getChildren() {
|
public ICElement[] getChildren() {
|
||||||
CElementInfo info = getElementInfo();
|
CElementInfo info = getElementInfo();
|
||||||
if (info != null)
|
if (info != null)
|
||||||
return getElementInfo().getChildren();
|
return info.getChildren();
|
||||||
else
|
else
|
||||||
return new ICElement[]{};
|
return new ICElement[]{};
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,6 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ITranslationUnit
|
* @see ITranslationUnit
|
||||||
|
@ -478,8 +475,8 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
*/
|
*/
|
||||||
public Map parse(){
|
public Map parse(){
|
||||||
removeChildren(this);
|
removeChildren(this);
|
||||||
final CModelBuilder modelBuilder = new CModelBuilder(this);
|
CModelBuilder modelBuilder = new CModelBuilder(this);
|
||||||
final boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode());
|
boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode());
|
||||||
try {
|
try {
|
||||||
return modelBuilder.parse(quickParseMode);
|
return modelBuilder.parse(quickParseMode);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue