From c244cfecf654d34032585530f00d68501ec63d77 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 12 Nov 2007 23:01:14 -0600 Subject: 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 --- lib/libalpm/be_files.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/libalpm/be_files.c') diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index a6cde689..ed8c8c14 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -44,6 +44,7 @@ #include "handle.h" #include "package.h" #include "delta.h" +#include "deps.h" /* This function is used to convert the downloaded db file to the proper backend @@ -455,7 +456,8 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) _alpm_strtrim(line); if(!strcmp(line, "%DEPENDS%")) { while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { - info->depends = alpm_list_add(info->depends, strdup(line)); + pmdepend_t *dep = alpm_splitdep(line); + info->depends = alpm_list_add(info->depends, dep); } } else if(!strcmp(line, "%OPTDEPENDS%")) { while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { @@ -670,7 +672,9 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) if(info->depends) { fputs("%DEPENDS%\n", fp); for(lp = info->depends; lp; lp = lp->next) { - fprintf(fp, "%s\n", (char *)lp->data); + char *depstring = alpm_dep_get_string(lp->data); + fprintf(fp, "%s\n", depstring); + free(depstring); } fprintf(fp, "\n"); } -- cgit v1.2.3-70-g09d2