On 07/02/2017 20:17, Roger Leigh wrote:

Looking at the implementation in
http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMNodeListImpl.cpp?view=markup#l64
it looks like it's due to the indexed access being O(n) rather than O(1)
[...]
Questions:

- Is this a known problem?  It looks like a fairly fundamental design
problem with the node list
- Is there any known workaround?
- Is there any alternative way to do a linear walk of the node list
using the public API and avoiding the index-based access offered by the
DOMNodeList API?

Testing with the DOMNode getFirstChild() and getNextSibling() methods, this improves the performance for one of my tests by over two orders of magnitude. So that seems to be an adequate workaround for now.

However, I'd certainly be very interested in any other approaches anyone could recommend, and also still interested in any rationale behind the performance of DOMNodeList; the Java implementation doesn't appear to suffer from the same problem--looking at https://svn.apache.org/repos/asf/xerces/java/branches/xerces_j_2/src/org/apache/xerces/dom/ParentNode.java the getLength() and item() methods implement a caching strategy to optimise queries, which the C++ implementation lacks. Would such a strategy be viable for the C++ codebase?


Regards,
Roger

Reply via email to