Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2015-03-11 03:15:29 +0000
committerAlex Blewitt2015-03-11 04:07:21 +0000
commit9fa3ff029333fabef82b1f8dcf3006af9c4d9d01 (patch)
tree84297c2559ac04d0a2c6107bc8f5e30b7694fa23 /bundles/org.eclipse.equinox.p2.repository
parent97c049de6141ed78adc45f6083aeb9ff447bfd0c (diff)
downloadrt.equinox.p2-9fa3ff029333fabef82b1f8dcf3006af9c4d9d01.tar.gz
rt.equinox.p2-9fa3ff029333fabef82b1f8dcf3006af9c4d9d01.tar.xz
rt.equinox.p2-9fa3ff029333fabef82b1f8dcf3006af9c4d9d01.zip
To minimise the impact of GC sweeps during repository parsing, store a cache of URIs against the String location against the XML parser. Change-Id: I9f4c0456c2c798cd031011340d386540dc5c9161 Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
index 01aa1a396..a22475d63 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
@@ -4,15 +4,14 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.internal.p2.persistence;
import java.net.*;
-import java.util.List;
-import java.util.StringTokenizer;
+import java.util.*;
import javax.xml.parsers.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.Activator;
@@ -46,6 +45,9 @@ public abstract class XMLParser extends DefaultHandler implements XMLConstants {
private IProgressMonitor monitor;
+ // Store a cache of previously seen URIs to avoid GC presure
+ final Map<String, URI> uris = new HashMap<String, URI>();
+
private static ServiceTracker<SAXParserFactory, SAXParserFactory> xmlTracker = null;
public XMLParser(BundleContext context, String pluginId) {
@@ -270,6 +272,17 @@ public abstract class XMLParser extends DefaultHandler implements XMLConstants {
*/
protected URI parseURIAttribute(Attributes attributes, boolean required) {
String location = parseOptionalAttribute(attributes, URI_ATTRIBUTE);
+ URI uri = location == null ? null : XMLParser.this.uris.get(location);
+ if (uri == null) {
+ uri = constructURI(attributes, required, location);
+ if (uri != null) {
+ XMLParser.this.uris.put(location, uri);
+ }
+ }
+ return uri;
+ }
+
+ private URI constructURI(Attributes attributes, boolean required, String location) {
try {
if (location != null)
return new URI(location);

Back to the top