mrglavas 2004/07/12 20:32:22
Modified: java/src/org/apache/xerces/dom TextImpl.java
Log:
Performance fix. Getting the length of a node list causes
the traveral of a linked list. Walk the child/sibling chain
instead of by index with node lists.
Revision Changes Path
1.26 +13 -9 xml-xerces/java/src/org/apache/xerces/dom/TextImpl.java
Index: TextImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/TextImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- TextImpl.java 30 Jun 2004 18:26:36 -0000 1.25
+++ TextImpl.java 13 Jul 2004 03:32:22 -0000 1.26
@@ -458,20 +458,24 @@
private boolean hasTextOnlyChildren(Node node) {
Node child = node;
-
- if (child == null)
+
+ if (child == null) {
return false;
-
- for (int i = 0; i < child.getChildNodes().getLength(); i++) {
- int type = child.getChildNodes().item(i).getNodeType();
-
+ }
+
+ child = child.getFirstChild();
+ while (child != null) {
+ int type = child.getNodeType();
+
if (type == Node.ENTITY_REFERENCE_NODE) {
- return hasTextOnlyChildren(child.getChildNodes().item(i));
- } else if (type != Node.TEXT_NODE
+ return hasTextOnlyChildren(child);
+ }
+ else if (type != Node.TEXT_NODE
&& type != Node.CDATA_SECTION_NODE
&& type != Node.ENTITY_REFERENCE_NODE) {
return false;
}
+ child = child.getNextSibling();
}
return true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]