libxbps: performance improvements by caching the most accessed paths.
1- We can cache the result of the first xbps_pkgdb_init() when it fails and avoid the malloc/free/access from it. 2- We cache the uname(2) result into a private var in xbps_handle and use it in xbps_pkg_arch_match(). This improves performance by ~5% approx and it's close as it was before introducing the repository index format 1.5.
This commit is contained in:
@ -56,7 +56,7 @@ rmobsoletes_files_cb(struct xbps_handle *xhp,
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
if (xbps_find_pkg_in_array_by_pkgver(ifd->idx, pkgver, arch)) {
|
||||
if (xbps_find_pkg_in_array_by_pkgver(xhp, ifd->idx, pkgver, arch)) {
|
||||
/* pkg found, do nothing */
|
||||
return 0;
|
||||
}
|
||||
@ -95,7 +95,7 @@ genindex_files_cb(struct xbps_handle *xhp,
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
|
||||
if (xbps_find_pkg_in_array_by_pkgver(ifd->idxfiles, pkgver, arch)) {
|
||||
if (xbps_find_pkg_in_array_by_pkgver(xhp, ifd->idxfiles, pkgver, arch)) {
|
||||
fprintf(stderr, "index-files: skipping `%s' (%s), "
|
||||
"already registered.\n", pkgver, arch);
|
||||
return 0;
|
||||
@ -278,7 +278,7 @@ repo_genindex_files(struct xbps_handle *xhp, const char *pkgdir)
|
||||
}
|
||||
arch = strchr(p, ',') + 1;
|
||||
if (!xbps_remove_pkg_from_array_by_pkgver(
|
||||
ifd->idxfiles, pkgver, arch)) {
|
||||
xhp, ifd->idxfiles, pkgver, arch)) {
|
||||
free(pkgver);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
|
Reference in New Issue
Block a user