At 10.21 26/05/2004 -0400, Nath wrote:
Sure thing,
[..]
// Get word nodes
cXMLNodeList = cXMLDoc->getElementsByTagName(XMLString::transcode("word"));

Hi Nath,
I see a couple of spots that could affect performances:
1) getElementsByTagName navigates through all the nodes, and builds a list containing the elements with the name "word"; if you have a lot of them, it will take time and memory. Given that you later iterates over them, you should consider switching to a DOMTreeWalker/DOMNodeFilter approach.
2) when you get a "word" element, you invoke getChildNodes; this API should not be used when a lot of child nodes are present, as it emulates an array over a linked list. So, every time you call getLength it goes to the first node and starts counting until it arrives to the end; and when you call item(j) it does the same until it comes to the j-th element. Just replace them with getFirstChild/getNextSibling.


Alberto


// Loop through all word nodes
for (int i = 0; i < cXMLNodeList->getLength(); i++)
{
   // Obtain list of child nodes
   cChildNodeList = cXMLNodeList->item(i)->getChildNodes();

   // Loop through all child nodes
   for (int j = 0; j < cChildNodeList->getLength(); j++)
   {
      strcpy(name,
XMLString::transcode(cChildNodeList->item(j)->getTextContent());

      // . . . . definitions and whatnot are also copied here
   }
}



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to