<div class="gmail_quote">On Thu, Sep 2, 2010 at 1:52 PM, GOUJON Alexandre <span dir="ltr">&lt;<a href="mailto:ale.goujon@gmail.com">ale.goujon@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 09/02/2010 12:10 PM, Alexandre Julliard wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That&#39;s ugly and inefficient, especially since the common case is to not<br>
modify it.<br>
   <br>
</blockquote></div>
Well, in fact I don&#39;t modify the content.<br>
I just trim the output of bstr_from_xmlChar( xmlNodeGetContent( (xmlNodePtr)This-&gt;node ) )<br>
And I made a separate function to not overload xml_get_text.<br></blockquote><div><br></div><div>I think what Alexandre J means is that you are reallocating the buffer every time (even if there is no whitespace to trim), which is inefficient for the average case (in which there will be no whitespace to trim). You only have to reallocate the string if (j - i &lt; len - 1).</div>

<div><br></div><div>You could also try this hack: you don&#39;t have to reallocate the string even if it has whitespace, use memmove to get rid of the leading whitespace, then just set the string&#39;s length to j - i + 1.</div>

<div><br></div><div>Not sure if it makes sense to reallocate the string if it&#39;s empty.</div><div><br>Octavian</div><div><br></div></div>