[pacman-dev] [PATCH] alpm_checkdeps clean-up <- some notes

Nagy Gabor ngaba at bibl.u-szeged.hu
Fri Nov 30 18:43:21 EST 2007

> > > Well, I will create a cosmetics patch for this, soon [I am also
> > > quite busy
> > now,
> > > be patient ;-)]:
> > > 1. get rid of the ugly joined list [maybe with two for-loops] <-
> > > I used
> > this to
> > > avoid duplicated code, and indeed... the result is _really_ ugly
> > > 2. remove compute_requiredby, and check the whole "untouched"
> > > localdb by
> > hand
> > > [this is more suggestive imho, and a _little bit_ faster]
> > 
> > sounds good.
> Patch attached
Some notes:
+	joined = alpm_list_join(alpm_list_copy(remove), alpm_list_copy(upgrade));
+	dblist = alpm_list_diff(_alpm_db_get_pkgcache(db), joined, _alpm_pkg_cmp);
+	alpm_list_free(joined);
Well, this is done immediately after checkdeps call, which may be
unneeded (remove == NULL or upgrade == NULL, this is a usual case), and
dblist shouldn't be calculated if reverse==0 and we don't need it
(packages have no dependencies or satisfied by upgrade list).
+		alpm_list_t *modified = alpm_list_diff(_alpm_db_get_pkgcache(db), dblist, _alpm_pkg_cmp);
I would prefer "intersect(dbcache, joined)", because usually joined
is a smaller list than dblist, but we have no such function.
alpm_list_diff is quite fast (n+m), but it needs to order lists first
O(nlogn)+O(mlogm); however dbcache is initially(?) ordered.
Note: We had some alpm_list problems nowadays, after this patch
alpm_list_diff function becomes crucial...

Overall the new version is much more powerful (imho) if it must check
many targets, but point 1. shows that the current resolvedeps may
becomes slower after this patch, because checkdeps is called on all
packages (but see also my resolvedeps patch, which reduces checkdeps
calls in "usual" cases -- not smoke001.py-like)

Bye, ngaba

More information about the pacman-dev mailing list