[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: rev 4559 - trunk/subversion/libsvn_subr

From: <gstein_at_lyra.org>
Date: 2003-01-24 19:11:49 CET

On Fri, Jan 24, 2003 at 09:08:16AM -0600, cmpilato@collab.net wrote:
...
 I was wondering the other day if we shouldn't just do a single
 svn_stringbuf_ensure here. Either always do one at the beginning:
 
    svn_stringbuf_ensure(retstr, strlen (path) * 3) + 1);
 
    (This is worst case -- each char is replaced by three (%XX), and
     then room for the NULL at the end)
 
 Or, do it the first time we find a char that needs replacing (someone
 check my math):
 
    svn_stringbuf_ensure(retstr, copied + strlen (path + copied) * 3) + 1);
 
 Anyway, just an idea.

In apr_xml_quote_string, I coded a two-pass algorithm. One pass to count
the special chars, do the alloc, then a second pass to make the changes. The
neat part is that if no changes are necessary, it just returns the input
string without an alloc/copy.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 14 02:14:36 2006

This is an archived mail posted to the Subversion Dev mailing list.