Bug 251913 - [planner] High memory use in projector
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
index ffa6d87..1ec41ba 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
@@ -427,23 +427,29 @@
if (optionalityExpression == null)
optionalityExpression = " -1 " + iuVar + " 1 " + getNoOperationVariable(iu); //$NON-NLS-1$ //$NON-NLS-2$
StringBuffer comment = new StringBuffer();
- comment.append("* "); //$NON-NLS-1$
- comment.append(iu.toString());
- comment.append(" requires optionaly either "); //$NON-NLS-1$
+ if (DEBUG) {
+ comment.append("* "); //$NON-NLS-1$
+ comment.append(iu.toString());
+ comment.append(" requires optionaly either "); //$NON-NLS-1$
+ }
int countMatches = 0;
for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = (IInstallableUnit) iterator.next();
if (isApplicable(match)) {
countMatches++;
expression += " 1 " + getVariable(match); //$NON-NLS-1$
- comment.append(match.toString());
- comment.append(' ');
+ if (DEBUG) {
+ comment.append(match.toString());
+ comment.append(' ');
+ }
}
}
countOptionalIUs += countMatches;
if (countMatches > 0) {
- dependencies.add(comment.toString());
- commentsCount++;
+ if (DEBUG) {
+ dependencies.add(comment.toString());
+ commentsCount++;
+ }
dependencies.add(impliesNo(getNoOperationVariable(iu), abstractVar));
dependencies.add(expression + " >= 0;"); //$NON-NLS-1$
optionalityExpression += " 1 " + abstractVar; //$NON-NLS-1$
@@ -460,23 +466,29 @@
if (optionalityExpression == null)
optionalityExpression = " -1 " + getVariable(iu) + " 1 " + getNoOperationVariable(iu); //$NON-NLS-1$ //$NON-NLS-2$
StringBuffer comment = new StringBuffer();
- comment.append("* "); //$NON-NLS-1$
- comment.append(iu.toString());
- comment.append(" requires optionaly either "); //$NON-NLS-1$
+ if (DEBUG) {
+ comment.append("* "); //$NON-NLS-1$
+ comment.append(iu.toString());
+ comment.append(" requires optionaly either "); //$NON-NLS-1$
+ }
int countMatches = 0;
for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = (IInstallableUnit) iterator.next();
if (isApplicable(match)) {
countMatches++;
expression += " 1 " + getVariable(match); //$NON-NLS-1$
- comment.append(match.toString());
- comment.append(' ');
+ if (DEBUG) {
+ comment.append(match.toString());
+ comment.append(' ');
+ }
}
}
countOptionalIUs += countMatches;
if (countMatches > 0) {
- dependencies.add(comment.toString());
- commentsCount++;
+ if (DEBUG) {
+ dependencies.add(comment.toString());
+ commentsCount++;
+ }
dependencies.add(impliesNo(getNoOperationVariable(iu), abstractVar));
dependencies.add(expression + " " + value + ";"); //$NON-NLS-1$ //$NON-NLS-2$
optionalityExpression += " 1 " + abstractVar; //$NON-NLS-1$
@@ -490,23 +502,29 @@
String expression = varIu;
Collector matches = picker.query(new CapabilityQuery(req), new Collector(), null);
StringBuffer comment = new StringBuffer();
- comment.append("* "); //$NON-NLS-1$
- comment.append(iu.toString());
- comment.append(" requires either "); //$NON-NLS-1$
+ if (DEBUG) {
+ comment.append("* "); //$NON-NLS-1$
+ comment.append(iu.toString());
+ comment.append(" requires either "); //$NON-NLS-1$
+ }
int countMatches = 0;
for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = (IInstallableUnit) iterator.next();
if (isApplicable(match)) {
countMatches++;
expression += " +1 " + getVariable(match); //$NON-NLS-1$
- comment.append(match.toString());
- comment.append(' ');
+ if (DEBUG) {
+ comment.append(match.toString());
+ comment.append(' ');
+ }
}
}
if (countMatches > 0) {
- dependencies.add(comment.toString());
- commentsCount++;
+ if (DEBUG) {
+ dependencies.add(comment.toString());
+ commentsCount++;
+ }
dependencies.add(expression + " " + value + ";"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
result.add(new Status(IStatus.WARNING, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Planner_Unsatisfied_dependency, iu, req)));
@@ -521,23 +539,29 @@
String expression = "-1 " + varIu; //$NON-NLS-1$
Collector matches = picker.query(new CapabilityQuery(req), new Collector(), null);
StringBuffer comment = new StringBuffer();
- comment.append("* "); //$NON-NLS-1$
- comment.append(iu.toString());
- comment.append(" requires either "); //$NON-NLS-1$
+ if (DEBUG) {
+ comment.append("* "); //$NON-NLS-1$
+ comment.append(iu.toString());
+ comment.append(" requires either "); //$NON-NLS-1$
+ }
int countMatches = 0;
for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
IInstallableUnit match = (IInstallableUnit) iterator.next();
if (isApplicable(match)) {
countMatches++;
expression += " +1 " + getVariable(match); //$NON-NLS-1$
- comment.append(match.toString());
- comment.append(' ');
+ if (DEBUG) {
+ comment.append(match.toString());
+ comment.append(' ');
+ }
}
}
if (countMatches > 0) {
- dependencies.add(comment.toString());
- commentsCount++;
+ if (DEBUG) {
+ dependencies.add(comment.toString());
+ commentsCount++;
+ }
dependencies.add(expression + " >= 0;"); //$NON-NLS-1$
} else {
result.add(new Status(IStatus.WARNING, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Planner_Unsatisfied_dependency, iu, req)));