mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Memory optimizations
Optimize for a) no errors case (most of them) b) no dependencies case (all of the library nodes). These two account for around 50mb of memory usage GitOrigin-RevId: e92d6a1e5d50e7bfe94a41949905a576e80206d3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5dd3e42476
commit
ec0d5547a6
+21
-7
@@ -58,14 +58,17 @@ public abstract class ExternalSystemNode<T> extends SimpleNode implements Compar
|
||||
|
||||
protected static final ExternalSystemNode[] NO_CHILDREN = new ExternalSystemNode[0];
|
||||
|
||||
private static final List<ExternalSystemNode<?>> NO_CHILDREN_LIST = Collections.emptyList();
|
||||
private static final List<String> NO_ERRORS_LIST = Collections.emptyList();
|
||||
|
||||
private final ExternalProjectsView myExternalProjectsView;
|
||||
private final List<ExternalSystemNode<?>> myChildrenList = new ArrayList<>();
|
||||
private List<ExternalSystemNode<?>> myChildrenList = NO_CHILDREN_LIST;
|
||||
protected DataNode<T> myDataNode;
|
||||
@Nullable
|
||||
private ExternalSystemNode myParent;
|
||||
private ExternalSystemNode[] myChildren;
|
||||
private ExternalProjectsStructure.ErrorLevel myErrorLevel = ExternalProjectsStructure.ErrorLevel.NONE;
|
||||
private final List<String> myErrors = new ArrayList<>();
|
||||
private List<String> myErrors = NO_ERRORS_LIST;
|
||||
private ExternalProjectsStructure.ErrorLevel myTotalErrorLevel = null;
|
||||
|
||||
public ExternalSystemNode(@NotNull ExternalProjectsView externalProjectsView,
|
||||
@@ -209,7 +212,7 @@ public abstract class ExternalSystemNode<T> extends SimpleNode implements Compar
|
||||
|
||||
public void cleanUpCache() {
|
||||
myChildren = null;
|
||||
myChildrenList.clear();
|
||||
myChildrenList = NO_CHILDREN_LIST;
|
||||
myTotalErrorLevel = null;
|
||||
}
|
||||
|
||||
@@ -219,7 +222,9 @@ public abstract class ExternalSystemNode<T> extends SimpleNode implements Compar
|
||||
}
|
||||
|
||||
protected void sort(List<? extends ExternalSystemNode> list) {
|
||||
Collections.sort(list, ORDER_AWARE_COMPARATOR);
|
||||
if (!list.isEmpty()) {
|
||||
Collections.sort(list, ORDER_AWARE_COMPARATOR);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends ExternalSystemNode> externalSystemNodes) {
|
||||
@@ -229,6 +234,10 @@ public abstract class ExternalSystemNode<T> extends SimpleNode implements Compar
|
||||
private boolean addAll(Collection<? extends ExternalSystemNode> externalSystemNodes, boolean silently) {
|
||||
if (externalSystemNodes.isEmpty()) return false;
|
||||
|
||||
if (myChildrenList == NO_CHILDREN_LIST) {
|
||||
myChildrenList = new ArrayList<>();
|
||||
}
|
||||
|
||||
for (ExternalSystemNode externalSystemNode : externalSystemNodes) {
|
||||
externalSystemNode.setParent(this);
|
||||
myChildrenList.add(externalSystemNode);
|
||||
@@ -253,7 +262,7 @@ public abstract class ExternalSystemNode<T> extends SimpleNode implements Compar
|
||||
|
||||
for (ExternalSystemNode externalSystemNode : externalSystemNodes) {
|
||||
externalSystemNode.setParent(null);
|
||||
myChildrenList.remove(externalSystemNode);
|
||||
if (myChildrenList != NO_CHILDREN_LIST) myChildrenList.remove(externalSystemNode);
|
||||
}
|
||||
if (!silently) {
|
||||
childrenChanged();
|
||||
@@ -322,8 +331,13 @@ public abstract class ExternalSystemNode<T> extends SimpleNode implements Compar
|
||||
public void setErrorLevel(ExternalProjectsStructure.ErrorLevel level, String... errors) {
|
||||
if (myErrorLevel == level) return;
|
||||
myErrorLevel = level;
|
||||
myErrors.clear();
|
||||
Collections.addAll(myErrors, errors);
|
||||
|
||||
if (errors.length == 0) {
|
||||
myErrors = NO_ERRORS_LIST;
|
||||
}
|
||||
else {
|
||||
myErrors = Arrays.asList(errors);
|
||||
}
|
||||
myExternalProjectsView.updateUpTo(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user