From 6e994011f5fd38ca0e3320c1652623a167e906f0 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 16 Dec 2017 21:11:38 +0300 Subject: [PATCH] (vfs_path_url_split): minor optimization. Signed-off-by: Andrew Borodin --- lib/vfs/path.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/vfs/path.c b/lib/vfs/path.c index 352df7f7d..e59b6b603 100644 --- a/lib/vfs/path.c +++ b/lib/vfs/path.c @@ -236,13 +236,11 @@ static void vfs_path_url_split (vfs_path_element_t * path_element, const char *path) { char *pcopy; - const char *pend; char *colon, *at, *rest; path_element->port = 0; pcopy = g_strdup (path); - pend = pcopy + strlen (pcopy); /* search for any possible user */ at = strrchr (pcopy, '@'); @@ -252,9 +250,12 @@ vfs_path_url_split (vfs_path_element_t * path_element, const char *path) rest = pcopy; else { + const char *pend; char *inner_colon; + pend = strchr (at, '\0'); *at = '\0'; + inner_colon = strchr (pcopy, ':'); if (inner_colon != NULL) { @@ -280,9 +281,9 @@ vfs_path_url_split (vfs_path_element_t * path_element, const char *path) colon = strchr (++rest, ']'); if (colon != NULL) { - colon[0] = '\0'; - colon[1] = '\0'; + *colon = '\0'; colon++; + *colon = '\0'; path_element->ipv6 = TRUE; } }