mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
(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:
parent
a9ff27db05
commit
0073a137af
@ -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';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user