From: Brian Pane Date: Sun, 2 Dec 2001 05:09:51 +0000 (+0000) Subject: Modified ap_make_full_path to minimize the number of strlen operations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49f7f33d460281415cf9bfcd80b0411742424c61;p=apache Modified ap_make_full_path to minimize the number of strlen operations git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92280 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util.c b/server/util.c index 7eaa1dc041..8b12f85216 100644 --- a/server/util.c +++ b/server/util.c @@ -1692,16 +1692,26 @@ AP_DECLARE(int) ap_is_rdirectory(apr_pool_t *p, const char *path) AP_DECLARE(char *) ap_make_full_path(apr_pool_t *a, const char *src1, const char *src2) { - register int x; - - x = strlen(src1); - if (x == 0) - return apr_pstrcat(a, "/", src2, NULL); - - if (src1[x - 1] != '/') - return apr_pstrcat(a, src1, "/", src2, NULL); - else - return apr_pstrcat(a, src1, src2, NULL); + apr_size_t len1, len2; + char *path; + + len1 = strlen(src1); + len2 = strlen(src2); + path = (char *)apr_palloc(a, len1 + len2 + 2); /* +2 for '/' plus null */ + if (len1 == 0) { + *path = '/'; + memcpy(path + 1, src2, len2 + 1); + } + else { + char *next; + memcpy(path, src1, len1); + next = path + len1; + if (next[-1] != '/') { + *next++ = '/'; + } + memcpy(next, src2, len2 + 1); + } + return path; } /*