mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
(diff_two_paths): optimizate path comparision.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
72056890a7
commit
cebede5e84
13
lib/util.c
13
lib/util.c
@ -1028,6 +1028,7 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
char *r, *s;
|
char *r, *s;
|
||||||
|
ptrdiff_t len;
|
||||||
|
|
||||||
r = strchr (p, PATH_SEP);
|
r = strchr (p, PATH_SEP);
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
@ -1036,17 +1037,9 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
|||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
*r = '\0';
|
len = r - p;
|
||||||
*s = '\0';
|
if (len != (s - q) || strncmp (p, q, (size_t) len) != 0)
|
||||||
if (strcmp (p, q) != 0)
|
|
||||||
{
|
|
||||||
*r = PATH_SEP;
|
|
||||||
*s = PATH_SEP;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
*r = PATH_SEP;
|
|
||||||
*s = PATH_SEP;
|
|
||||||
|
|
||||||
p = r + 1;
|
p = r + 1;
|
||||||
q = s + 1;
|
q = s + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user