xbps_init: performance: do not chdir() unnecessarily for each conf file.

This commit is contained in:
Juan RP 2014-08-01 15:30:43 +02:00
parent f8d8f91a08
commit df93e790a6

View File

@ -227,15 +227,6 @@ parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nest
xbps_dbg_printf(xhp, "Parsing configuration file: %s\n", path);
}
/* cwd to the dir containing the config file */
strlcpy(tmppath, path, sizeof(tmppath));
cfcwd = dirname(tmppath);
if (chdir(cfcwd) == -1) {
rv = errno;
xbps_dbg_printf(xhp, "cannot chdir to %s: %s\n", cfcwd, strerror(rv));
return rv;
}
while ((read = getline(&line, &len, fp)) != -1) {
char *p, *k, *v;
@ -283,6 +274,14 @@ parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nest
if (strcmp(k, "include"))
continue;
/* cwd to the dir containing the config file */
strlcpy(tmppath, path, sizeof(tmppath));
cfcwd = dirname(tmppath);
if (chdir(cfcwd) == -1) {
rv = errno;
xbps_dbg_printf(xhp, "cannot chdir to %s: %s\n", cfcwd, strerror(rv));
return rv;
}
if ((rv = parse_files_glob(xhp, cwd, v, true, false)) != 0)
break;