You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/10/22 22:44:00 UTC
svn commit: r1710099 - /subversion/trunk/subversion/libsvn_subr/path.c
Author: stefan2
Date: Thu Oct 22 20:44:00 2015
New Revision: 1710099
URL: http://svn.apache.org/viewvc?rev=1710099&view=rev
Log:
Triple the performance of our URI escapement code when applied to already
valid input. This function is at the core of svn_path_url_add_component2(),
which in turn is called all over the place.
* subversion/libsvn_subr/path.c
(uri_escape): Delay any escapement overhead until we find the first
character that needs escaping.
Modified:
subversion/trunk/subversion/libsvn_subr/path.c
Modified: subversion/trunk/subversion/libsvn_subr/path.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/path.c?rev=1710099&r1=1710098&r2=1710099&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/path.c (original)
+++ subversion/trunk/subversion/libsvn_subr/path.c Thu Oct 22 20:44:00 2015
@@ -910,9 +910,20 @@ uri_escape(const char *path, const char
svn_stringbuf_t *retstr;
apr_size_t i, copied = 0;
int c;
+ apr_size_t len = strlen(path);
+ const char *p, *end;
- retstr = svn_stringbuf_create_ensure(strlen(path), pool);
- for (i = 0; path[i]; i++)
+ /* Quick check: Does any character need escaping? */
+ for (p = path, end = p + len; p < end; ++p)
+ if (!table[(unsigned char)*p])
+ break;
+
+ if (p == end)
+ return path;
+
+ /* We need to escape at least one character. */
+ retstr = svn_stringbuf_create_ensure(len, pool);
+ for (i = p - path; i < len; i++)
{
c = (unsigned char)path[i];
if (table[c])
@@ -941,10 +952,6 @@ uri_escape(const char *path, const char
copied = i + 1;
}
- /* If we didn't encode anything, we don't need to duplicate the string. */
- if (retstr->len == 0)
- return path;
-
/* Anything left to copy? */
if (i - copied)
svn_stringbuf_appendbytes(retstr, path + copied, i - copied);