summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/conflict.c
diff options
context:
space:
mode:
authorNagy Gabor <ngaba@petra.hos.u-szeged.hu>2007-08-05 17:50:24 +0200
committerDan McGee <dan@archlinux.org>2007-08-13 03:15:37 +0200
commit3a0a4db12936199efd0ee1714b7219fab3d83392 (patch)
tree2b9fee13e49e8c793b1863b620f3db5d93a29682 /lib/libalpm/conflict.c
parentab06221521cd38299743f33c3c5a0d81cbd3f589 (diff)
downloadpacman-3a0a4db12936199efd0ee1714b7219fab3d83392.tar.gz
pacman-3a0a4db12936199efd0ee1714b7219fab3d83392.tar.xz
libalpm/conflict.c : small speed-up and fix.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Diffstat (limited to 'lib/libalpm/conflict.c')
-rw-r--r--lib/libalpm/conflict.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index feb42755..46d1f227 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -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 *targets = trans->packages;
int numtargs = alpm_list_count(targets);
+ int current;
ALPM_LOG_FUNC;
@@ -279,7 +280,7 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
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;
pmpkg_t *p1, *p2, *dbpkg;
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;
}
- double percent = (double)(alpm_list_count(targets) - alpm_list_count(i) + 1)
- / alpm_list_count(targets);
+ double percent = (double)current / numtargs;
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 */
for(j = i->next; j; j = j->next) {
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;
for(k = dbpkg->files; k; k = k->next) {
snprintf(str, PATH_MAX, "%s%s", root, (char*)k->data);
- lstat(str, &buf2);
- if(buf.st_ino == buf2.st_ino) {
+ if(!lstat(str, &buf2) && buf.st_ino == buf2.st_ino) {
ok = 1;
_alpm_log(PM_LOG_DEBUG, "conflict was a symlink: %s", path);
break;