Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-11-12 23:01:14 -0600
committerDan McGee <dan@archlinux.org>2007-11-14 21:00:02 -0600
commitc244cfecf654d34032585530f00d68501ec63d77 (patch)
tree36c5a35953573e0038c7b89ea26f568b0e081f16 /lib/libalpm/package.c
parent8757398a7e3132166a2e20605c02dfdc2abc3d1d (diff)
Move alpm_splitdep usage to db_read
Holy inefficient batman! For a pacman -Qt operation (when we are using compute_requiredby and not database entries), splitdep was being called ~1.3 million times on my local database. By splitting when we read the DB, we drop this number to around 1700 and save a LOT of time in doing so (a 5x increase in pacman -Qt speed here). Note that the depends alpm_list_t in the package struct is no longer a string list, but a list of pmdepent_t objects. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 89785a14..2c6fc29c 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -49,7 +49,7 @@
#include "delta.h"
#include "provide.h"
#include "handle.h"
-#include "alpm.h"
+#include "deps.h"
/** \addtogroup alpm_packages Package Functions
* @brief Functions to manipulate libalpm packages
@@ -527,22 +527,13 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
const char *cachepkgname = alpm_pkg_get_name(cachepkg);
for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
- pmdepend_t *dep;
+ pmdepend_t *dep = j->data;
- if(!j->data) {
- continue;
- }
- dep = alpm_splitdep(j->data);
- if(dep == NULL) {
- continue;
- }
-
if(alpm_depcmp(pkg, dep)) {
_alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'\n",
cachepkgname, pkg->name);
reqs = alpm_list_add(reqs, strdup(cachepkgname));
}
- FREE(dep);
}
}
return(reqs);
@@ -684,7 +675,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
newpkg->conflicts = alpm_list_strdup(alpm_pkg_get_conflicts(pkg));
newpkg->files = alpm_list_strdup(alpm_pkg_get_files(pkg));
newpkg->backup = alpm_list_strdup(alpm_pkg_get_backup(pkg));
- newpkg->depends = alpm_list_strdup(alpm_pkg_get_depends(pkg));
+ newpkg->depends = alpm_list_copy_data(alpm_pkg_get_depends(pkg));
newpkg->optdepends = alpm_list_strdup(alpm_pkg_get_optdepends(pkg));
newpkg->groups = alpm_list_strdup(alpm_pkg_get_groups(pkg));
newpkg->provides = alpm_list_strdup(alpm_pkg_get_provides(pkg));
@@ -851,7 +842,8 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
/* size in the raw package is uncompressed (installed) size */
info->isize = atol(ptr);
} else if(!strcmp(key, "depend")) {
- info->depends = alpm_list_add(info->depends, strdup(ptr));
+ pmdepend_t *dep = alpm_splitdep(ptr);
+ info->depends = alpm_list_add(info->depends, dep);
} else if(!strcmp(key, "optdepend")) {
info->optdepends = alpm_list_add(info->optdepends, strdup(ptr));
} else if(!strcmp(key, "conflict")) {