On Wed, Jul 02, 2008 at 07:15:00PM +0800, Ashwin wrote: > Hi Daniel, Hi Ashwin
> I have a query regarding the buffer allocation scheme used in > libxml, each time a document is sent for parsing libxml creates a buffer of > size 4k*2 initially, and then increases this if the doc happens to exceed > this size. My query is, whether there is some specific reason why the > original buffer is not used, rather than allocating another buffer and doing > a memmove. Good question, it's an optimization I tried to do ... I have looked at that a long time ago. Basically you would need to mark the buffer immutable (that is easy) but also change the parser low level to detect the end not on the 0 byte in the termination string but based on the index in the string (since the API can take any kind of encoding, the API uses a string lenght index, but internally the last character is detected via the 0 character at the end). An intermediate approach could have been to start parsing directly from an immutable buffer based on the input string and just switch to a small normal buffer when getting to the end of the input. But in any case those were significant code changes in really critical parts of the parser and I had stability problems with the result so I dropped the patch and never commited it. I guess the improvement would interest only those using libxml2 in embedded system, and well your question seems to confirm this ;-) Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
