libalpm/conflict.c : small speed-up and fix.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
This commit is contained in:
Nagy Gabor 2007-08-05 17:50:24 +02:00 committed by Dan McGee
parent ab06221521
commit 3a0a4db129
1 changed files with 5 additions and 6 deletions

View File

@ -272,6 +272,7 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
alpm_list_t *i, *conflicts = NULL; alpm_list_t *i, *conflicts = NULL;
alpm_list_t *targets = trans->packages; alpm_list_t *targets = trans->packages;
int numtargs = alpm_list_count(targets); int numtargs = alpm_list_count(targets);
int current;
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
@ -279,7 +280,7 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
return(NULL); return(NULL);
} }
for(i = targets; i; i = i->next) { for(current = 1, i = targets; i; i = i->next, current++) {
alpm_list_t *j, *k, *tmpfiles = NULL; alpm_list_t *j, *k, *tmpfiles = NULL;
pmpkg_t *p1, *p2, *dbpkg; pmpkg_t *p1, *p2, *dbpkg;
char path[PATH_MAX+1]; char path[PATH_MAX+1];
@ -289,10 +290,9 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
continue; continue;
} }
double percent = (double)(alpm_list_count(targets) - alpm_list_count(i) + 1) double percent = (double)current / numtargs;
/ alpm_list_count(targets);
PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100),
numtargs, (numtargs - alpm_list_count(i) +1)); numtargs, current);
/* CHECK 1: check every target against every target */ /* CHECK 1: check every target against every target */
for(j = i->next; j; j = j->next) { for(j = i->next; j; j = j->next) {
p2 = j->data; p2 = j->data;
@ -356,8 +356,7 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
unsigned ok = 0; unsigned ok = 0;
for(k = dbpkg->files; k; k = k->next) { for(k = dbpkg->files; k; k = k->next) {
snprintf(str, PATH_MAX, "%s%s", root, (char*)k->data); snprintf(str, PATH_MAX, "%s%s", root, (char*)k->data);
lstat(str, &buf2); if(!lstat(str, &buf2) && buf.st_ino == buf2.st_ino) {
if(buf.st_ino == buf2.st_ino) {
ok = 1; ok = 1;
_alpm_log(PM_LOG_DEBUG, "conflict was a symlink: %s", path); _alpm_log(PM_LOG_DEBUG, "conflict was a symlink: %s", path);
break; break;