XMLSerializer speedup.

This commit is contained in:
Harald Kuhr 2019-02-12 20:44:34 +01:00
parent 7fad4d5cd8
commit caef9b6a9e

View File

@ -389,9 +389,10 @@ public class XMLSerializer {
private void writeDocument(final PrintWriter pOut, final Node pNode, final SerializationContext pContext) { private void writeDocument(final PrintWriter pOut, final Node pNode, final SerializationContext pContext) {
// Document fragments might not have child nodes... // Document fragments might not have child nodes...
if (pNode.hasChildNodes()) { if (pNode.hasChildNodes()) {
NodeList nodes = pNode.getChildNodes(); Node child = pNode.getFirstChild();
for (int i = 0; i < nodes.getLength(); i++) { while (child != null) {
writeNodeRecursive(pOut, nodes.item(i), pContext); writeNodeRecursive(pOut, child, pContext);
child = child.getNextSibling();
} }
} }
} }
@ -448,9 +449,10 @@ public class XMLSerializer {
pOut.println(); pOut.println();
} }
NodeList children = pNode.getChildNodes(); Node child = pNode.getFirstChild();
for (int i = 0; i < children.getLength(); i++) { while (child != null) {
writeNodeRecursive(pOut, children.item(i), pContext.push()); writeNodeRecursive(pOut, child, pContext.push());
child = child.getNextSibling();
} }
if (!pContext.preserveSpace) { if (!pContext.preserveSpace) {