(diff_two_paths): optimizate path comparision.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2017-06-07 17:22:05 +03:00
parent 72056890a7
commit cebede5e84
1 changed files with 3 additions and 10 deletions

View File

@ -1028,6 +1028,7 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
while (TRUE)
{
char *r, *s;
ptrdiff_t len;
r = strchr (p, PATH_SEP);
if (r == NULL)
@ -1036,17 +1037,9 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
if (s == NULL)
break;
*r = '\0';
*s = '\0';
if (strcmp (p, q) != 0)
{
*r = PATH_SEP;
*s = PATH_SEP;
len = r - p;
if (len != (s - q) || strncmp (p, q, (size_t) len) != 0)
break;
}
*r = PATH_SEP;
*s = PATH_SEP;
p = r + 1;
q = s + 1;