mkwan 2003/02/17 12:31:33
Modified: java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
DOMAdapter.java DOMWSFilter.java
Log:
XSLTC_DTM performance work
Improvement for xsl:strip-space. Store the mappings in a Hashtable
so that the getMapping() interface only needs to be called once,
instead of being called every time from DOMWSFilter.getShouldStripSpace().
Revision Changes Path
No revision
No revision
1.11.10.13 +2 -4
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
Index: DOMAdapter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
retrieving revision 1.11.10.12
retrieving revision 1.11.10.13
diff -u -r1.11.10.12 -r1.11.10.13
--- DOMAdapter.java 30 Jan 2003 18:41:46 -0000 1.11.10.12
+++ DOMAdapter.java 17 Feb 2003 20:31:33 -0000 1.11.10.13
@@ -120,9 +120,7 @@
}
private short[] getMapping() {
- if (_mapping == null
- || (_saxImpl != null && _saxImpl.getNamesArray() == null)
- || (_domImpl != null && _domImpl.getNamesArray() == null)) {
+ if (_mapping == null) {
if (_domImpl != null) {
_mapping = _domImpl.getMapping(_namesArray);
} else {
1.1.2.5 +37 -8
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/DOMWSFilter.java
Index: DOMWSFilter.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/DOMWSFilter.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- DOMWSFilter.java 30 Jan 2003 18:41:46 -0000 1.1.2.4
+++ DOMWSFilter.java 17 Feb 2003 20:31:33 -0000 1.1.2.5
@@ -62,6 +62,7 @@
import org.apache.xalan.xsltc.DOM;
import org.apache.xalan.xsltc.StripFilter;
import org.apache.xalan.xsltc.runtime.AbstractTranslet;
+import org.apache.xalan.xsltc.runtime.Hashtable;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMWSFilter;
@@ -74,6 +75,9 @@
private AbstractTranslet m_translet;
private StripFilter m_filter;
+
+ // The Hashtable for DTM to mapping array
+ private Hashtable m_mappings;
/**
* Construct an adapter connecting the <code>DTMWSFilter</code> interface
@@ -87,6 +91,7 @@
*/
public DOMWSFilter(AbstractTranslet translet) {
m_translet = translet;
+ m_mappings = new Hashtable();
if (translet instanceof StripFilter) {
m_filter = (StripFilter) translet;
@@ -106,20 +111,44 @@
* <code>INHERIT</code>.
*/
public short getShouldStripSpace(int node, DTM dtm) {
- if (m_filter != null && m_translet != null && dtm instanceof DOM) {
+ if (m_filter != null && dtm instanceof DOM) {
DOM dom = (DOM)dtm;
int type = 0;
if (dtm instanceof SAXImpl) {
SAXImpl saxImpl = (SAXImpl)dtm;
- short[] mapping =
- saxImpl.getMapping(m_translet.getNamesArray());
- type = mapping[saxImpl.getExpandedTypeID(node)];
+
+ short[] mapping = (short[])m_mappings.get(dtm);
+ if (mapping == null) {
+ mapping = saxImpl.getMapping(m_translet.getNamesArray());
+ m_mappings.put(dtm, mapping);
+ }
+
+ int expType = saxImpl.getExpandedTypeID(node);
+
+ // %OPT% The mapping array does not have information about
all the
+ // exptypes. However it does contain enough information
about all names
+ // in the translet's namesArray. If the expType does not
fall into the
+ // range of the mapping array, it means that the expType is
not for one
+ // of the recognized names. In this case we can just set the
type to -1.
+ if (expType >= 0 && expType < mapping.length)
+ type = mapping[expType];
+ else
+ type = -1;
+
} else if (dtm instanceof DOMImpl) {
DOMImpl domImpl = (DOMImpl)dtm;
- short[] mapping =
- domImpl.getMapping(m_translet.getNamesArray());
- type = mapping[domImpl.getExpandedTypeID(node)];
+ short[] mapping = (short[])m_mappings.get(dtm);
+ if (mapping == null) {
+ mapping = domImpl.getMapping(m_translet.getNamesArray());
+ m_mappings.put(dtm, mapping);
+ }
+
+ int expType = domImpl.getExpandedTypeID(node);
+ if (expType >= 0 && expType < mapping.length)
+ type = mapping[expType];
+ else
+ type = -1;
} else {
return INHERIT;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]