You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/12/12 18:51:24 UTC
svn commit: r603686 - in /xerces/java/trunk/src/org/apache/xerces/dom:
DOMImplementationListImpl.java DOMImplementationSourceImpl.java
DOMXSImplementationSourceImpl.java
Author: mrglavas
Date: Wed Dec 12 09:51:23 2007
New Revision: 603686
URL: http://svn.apache.org/viewvc?rev=603686&view=rev
Log:
Minor performance improvement. Use an (unsynchronized) ArrayList instead of
a Vector as the container for the DOMImplementations in the DOMImplementationList.
Modified:
xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationListImpl.java
xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationSourceImpl.java
xerces/java/trunk/src/org/apache/xerces/dom/DOMXSImplementationSourceImpl.java
Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationListImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationListImpl.java?rev=603686&r1=603685&r2=603686&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationListImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationListImpl.java Wed Dec 12 09:51:23 2007
@@ -17,6 +17,7 @@
package org.apache.xerces.dom;
+import java.util.ArrayList;
import java.util.Vector;
import org.w3c.dom.DOMImplementationList;
import org.w3c.dom.DOMImplementation;
@@ -31,21 +32,28 @@
*/
public class DOMImplementationListImpl implements DOMImplementationList {
- //A collection of DOMImplementations
- private Vector fImplementations;
+ // A collection of DOMImplementations
+ private final ArrayList fImplementations;
/**
* Construct an empty list of DOMImplementations
*/
public DOMImplementationListImpl() {
- fImplementations = new Vector();
+ fImplementations = new ArrayList();
+ }
+
+ /**
+ * Construct a list of DOMImplementations from an ArrayList
+ */
+ public DOMImplementationListImpl(ArrayList params) {
+ fImplementations = params;
}
- /**
- * Construct an empty list of DOMImplementations
- */
+ /**
+ * Construct a list of DOMImplementations from a Vector
+ */
public DOMImplementationListImpl(Vector params) {
- fImplementations = params;
+ fImplementations = new ArrayList(params);
}
/**
@@ -54,11 +62,11 @@
* @param index The index of the DOMImplemetation from the list to return.
*/
public DOMImplementation item(int index) {
- try {
- return (DOMImplementation) fImplementations.elementAt(index);
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
+ final int length = getLength();
+ if (index >= 0 && index < length) {
+ return (DOMImplementation) fImplementations.get(index);
}
+ return null;
}
/**
Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationSourceImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationSourceImpl.java?rev=603686&r1=603685&r2=603686&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationSourceImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationSourceImpl.java Wed Dec 12 09:51:23 2007
@@ -17,12 +17,12 @@
package org.apache.xerces.dom;
+import java.util.ArrayList;
import java.util.StringTokenizer;
-import java.util.Vector;
+
+import org.w3c.dom.DOMImplementation;
import org.w3c.dom.DOMImplementationList;
import org.w3c.dom.DOMImplementationSource;
-import org.w3c.dom.DOMImplementation;
-import org.apache.xerces.dom.DOMImplementationListImpl;
/**
* Supply one the right implementation, based upon requested features. Each
@@ -78,13 +78,13 @@
public DOMImplementationList getDOMImplementationList(String features) {
// first check whether the CoreDOMImplementation would do
DOMImplementation impl = CoreDOMImplementationImpl.getDOMImplementation();
- final Vector implementations = new Vector();
+ final ArrayList implementations = new ArrayList();
if (testImpl(impl, features)) {
- implementations.addElement(impl);
+ implementations.add(impl);
}
impl = DOMImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
- implementations.addElement(impl);
+ implementations.add(impl);
}
return new DOMImplementationListImpl(implementations);
Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMXSImplementationSourceImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DOMXSImplementationSourceImpl.java?rev=603686&r1=603685&r2=603686&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMXSImplementationSourceImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMXSImplementationSourceImpl.java Wed Dec 12 09:51:23 2007
@@ -17,10 +17,11 @@
package org.apache.xerces.dom;
+import java.util.ArrayList;
+
import org.apache.xerces.impl.xs.XSImplementationImpl;
-import org.w3c.dom.DOMImplementationList;
import org.w3c.dom.DOMImplementation;
-import java.util.Vector;
+import org.w3c.dom.DOMImplementationList;
/**
* Allows to retrieve <code>XSImplementation</code>, DOM Level 3 Core and LS implementations
@@ -75,23 +76,23 @@
* features.
*/
public DOMImplementationList getDOMImplementationList(String features) {
- final Vector implementations = new Vector();
-
+ final ArrayList implementations = new ArrayList();
+
// first check whether the CoreDOMImplementation would do
DOMImplementationList list = super.getDOMImplementationList(features);
- //Add core DOMImplementations
- for (int i=0; i < list.getLength(); i++ ) {
- implementations.addElement(list.item(i));
+ // Add core DOMImplementations
+ for (int i = 0; i < list.getLength(); ++i) {
+ implementations.add(list.item(i));
}
-
+
DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
- implementations.addElement(impl);
+ implementations.add(impl);
}
-
+
impl = XSImplementationImpl.getDOMImplementation();
if (testImpl(impl, features)) {
- implementations.addElement(impl);
+ implementations.add(impl);
}
return new DOMImplementationListImpl(implementations);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org