Greg Stein gstein@lyra.org writes:
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.
We could do the same pretty easily. The test for URI-safeness is easy
and fast, and this beats XML-encoding by just a hair on the size test
because it's a flat 1-char-to-3-chars expansion for each unsafe byte.
Wanna code it up?
---------------------------------------------------------------------
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:45 2006