Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-06-02 22:12:41 -0400
committerspingel2010-06-02 22:12:41 -0400
commit1380c14b8e9f62bc252f84e07d9c9bc69295cc24 (patch)
treeb95fb3324c1ba3f86656abafeb34c9112cd24949 /org.eclipse.mylyn.tasks.core
parent6363bdd4c7a20f5738157862779e7754ff0185d0 (diff)
downloadorg.eclipse.mylyn.tasks-1380c14b8e9f62bc252f84e07d9c9bc69295cc24.tar.gz
org.eclipse.mylyn.tasks-1380c14b8e9f62bc252f84e07d9c9bc69295cc24.tar.xz
org.eclipse.mylyn.tasks-1380c14b8e9f62bc252f84e07d9c9bc69295cc24.zip
NEW - bug 315513: [performance] reduce memory footprint
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315513
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java10
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AttributeMap.java4
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java37
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java4
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java2
5 files changed, 40 insertions, 17 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
index 9acf57010..d0f0bd38d 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
@@ -126,7 +126,7 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
@Deprecated
public void setLastReadTimeStamp(String lastReadTimeStamp) {
- this.lastReadTimeStamp = lastReadTimeStamp;
+ this.lastReadTimeStamp = lastReadTimeStamp.intern();
}
/**
@@ -167,7 +167,7 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
public void setOwner(String owner) {
if (!areEqual(this.owner, owner)) {
String oldValue = this.owner;
- this.owner = owner;
+ this.owner = owner.intern();
firePropertyChange("owner", oldValue, owner); //$NON-NLS-1$
}
}
@@ -197,7 +197,7 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
}
public final void setRepositoryUrl(String repositoryUrl) {
- this.repositoryUrl = repositoryUrl;
+ this.repositoryUrl = repositoryUrl.intern();
super.setHandleIdentifier(RepositoryTaskHandleUtil.getHandle(repositoryUrl, taskId));
}
@@ -270,7 +270,7 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
public void setPriority(String priority) {
if (!areEqual(this.priority, priority)) {
String oldValue = this.priority;
- this.priority = priority;
+ this.priority = priority.intern();
firePropertyChange("priority", oldValue, priority); //$NON-NLS-1$
}
}
@@ -413,7 +413,7 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
public void setTaskKind(String taskKind) {
if (!areEqual(this.taskKind, taskKind)) {
String oldValue = this.taskKind;
- this.taskKind = taskKind;
+ this.taskKind = taskKind.intern();
firePropertyChange("taskKind", oldValue, taskKind); //$NON-NLS-1$
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AttributeMap.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AttributeMap.java
index 70b5888c4..438175025 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AttributeMap.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AttributeMap.java
@@ -24,7 +24,7 @@ public class AttributeMap {
private final Map<String, String> attributes;
public AttributeMap() {
- attributes = new HashMap<String, String>();
+ attributes = new HashMap<String, String>(4);
}
public String getAttribute(String key) {
@@ -40,7 +40,7 @@ public class AttributeMap {
if (value == null) {
attributes.remove(key);
} else {
- attributes.put(key, value);
+ attributes.put(key.intern(), value.intern());
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java
index b1c9b8825..95ceb47db 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/externalization/TaskListExternalizer.java
@@ -85,10 +85,19 @@ public class TaskListExternalizer {
private final List<Node> orphanedNodes = new ArrayList<Node>();
+ private Document orphanedDocument;
+
private String readVersion = ""; //$NON-NLS-1$
public TaskListExternalizer(RepositoryModel repositoryModel, IRepositoryManager repositoryManager) {
this.delegatingExternalizer = new DelegatingTaskExternalizer(repositoryModel, repositoryManager);
+ try {
+ this.orphanedDocument = createDocument();
+ } catch (CoreException e) {
+ this.orphanedDocument = null;
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Failed to create document for orphaned nodes", e));
+ }
}
public void initialize(List<AbstractTaskListMigrator> migrators) {
@@ -197,6 +206,13 @@ public class TaskListExternalizer {
delegatingExternalizer.reset();
orphanedNodes.clear();
+ try {
+ this.orphanedDocument = createDocument();
+ } catch (CoreException e) {
+ this.orphanedDocument = null;
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Failed to create document for orphaned nodes", e));
+ }
Document doc = openTaskList(inFile);
Element root = doc.getDocumentElement();
@@ -221,7 +237,7 @@ public class TaskListExternalizer {
tasksWithSubtasks.put(task, child.getChildNodes());
}
} else {
- orphanedNodes.add(child);
+ addOrphan(child);
}
}
}
@@ -242,7 +258,7 @@ public class TaskListExternalizer {
delegatingExternalizer.readTaskReferences(query, child.getChildNodes(), taskList);
}
} else {
- orphanedNodes.add(child);
+ addOrphan(child);
}
}
}
@@ -271,14 +287,21 @@ public class TaskListExternalizer {
// }
}
+ private void addOrphan(Node child) {
+ // copy node to separate document to avoid retaining entire dom
+ if (orphanedDocument != null) {
+ orphanedNodes.add(orphanedDocument.importNode(child, true));
+ } else {
+ orphanedNodes.add(child);
+ }
+ }
+
/**
- * Opens the specified XML file and parses it into a DOM Document.
- *
- * Filename - the name of the file to open Return - the Document built from the XML file Throws - XMLException if
- * the file cannot be parsed as XML - IOException if the file cannot be opened
+ * Opens the specified XML file and parses it into a DOM Document. Filename - the name of the file to open Return -
+ * the Document built from the XML file Throws - XMLException if the file cannot be parsed as XML - IOException if
+ * the file cannot be opened
*
* @throws CoreException
- *
*/
private Document openTaskList(File inputFile) throws CoreException {
InputStream in = null;
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
index 7acbbb184..9dba48661 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepository.java
@@ -292,7 +292,7 @@ public final class TaskRepository extends PlatformObject {
}
}
- @SuppressWarnings({ "unchecked" })
+ @SuppressWarnings( { "unchecked" })
private Map<String, String> getAuthInfo() {
synchronized (LOCK) {
if (Platform.isRunning()) {
@@ -811,7 +811,7 @@ public final class TaskRepository extends PlatformObject {
Assert.isLegal(!key.matches(".*\\s.*")); //$NON-NLS-1$
String oldValue = this.properties.get(key);
if ((oldValue != null && !oldValue.equals(newValue)) || (oldValue == null && newValue != null)) {
- this.properties.put(key, newValue);
+ this.properties.put(key.intern(), newValue.intern());
notifyChangeListeners(key, oldValue, newValue);
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
index c015bf3f2..69454093c 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
@@ -294,7 +294,7 @@ public final class TaskAttribute {
Assert.isNotNull(parentAttribute);
Assert.isNotNull(attributeId);
this.parentAttribute = parentAttribute;
- this.attributeId = attributeId;
+ this.attributeId = attributeId.intern();
this.taskData = parentAttribute.getTaskData();
this.values = new ArrayList<String>(1);
parentAttribute.add(this);

Back to the top