(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

View File

@ -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;