Re: [xml] xmlNewChild(...) slow in version 2.6.16-7 (debian sarge)

On Wed, Oct 24, 2007 at 11:07:21AM +0200, Dominik Raddatz wrote:

the following statement seems somewhat slow:

xmlNodePtr myNode;
xmlChar *myText;
xmlNewChild(myNode, NULL, BAD_CAST "description", BAD_CAST myText);

takes about 25 ms when myText is 50kB; profiling suggests it wastes much time 
using "xmlStrlen()".

the comparable statements

xmlNodePtr newNode=xmlNewChild(myNode, NULL, BAD_CAST "description", NULL);
xmlNodeAddContent(newNode, BAD_CAST myText);

are much faster, using less than 1 ms with the same text.

I haven't found any hint about whether this was a known problem and has been 
fixed in later versions.

  it's not comparable as far as I can tell.
The first one will scan (in xmlStringGetNodeList) for entities or
character references (maybe that can be optimized), and the later just
adds the string content as is as a text node value (via xmlNodeAddContentLen)


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]