(vfs_url_split): optimized to get rid of multiple string length caclulation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-04-03 16:48:55 +04:00 committed by Slava Zanko
parent 6e0c4b66b2
commit 3d4e6884d8

View File

@ -230,14 +230,16 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
vfs_path_element_t *path_element;
char *pcopy;
size_t pcopy_len;
const char *pend;
char *dir, *colon, *inner_colon, *at, *rest;
path_element = g_new0 (vfs_path_element_t, 1);
path_element->port = default_port;
pcopy = g_strdup (path);
pend = pcopy + strlen (pcopy);
pcopy_len = strlen (path);
pcopy = g_strndup (path, pcopy_len);
pend = pcopy + pcopy_len;
dir = pcopy;
if ((flags & URL_NOSLASH) == 0)
@ -249,7 +251,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
path_element->path = g_strdup (PATH_SEP_STR);
else
{
path_element->path = g_strdup (dir);
path_element->path = g_strndup (dir, pcopy_len - (size_t) (dir - pcopy));
*dir = '\0';
}
}