On Thu, Jul 19, 2007 at 09:28:42PM +0200, Nagy Gabor wrote:
Well, I thought the following method (pseudocode) for (pkg in pkgcache) { pkgdup = alpm_pkg_dup(pkg); clean_requiredby(pkgdup); _alpm_pkg_update_requiredby(pkgdup); good = sort_then_compare_requiredby(pkg, pkgdup); alpm_pkg_free(pkgdup); } ------------- depend checking is similar, just use alpm_checkdeps for a list containing pkgdup only.
I noted this on my TODO list and stopped looking at it, but I just started to look at it again. I see you had to clean the requiredby of the package before calling _alpm_pkg_update_requiredby. That's because _alpm_pkg_update_requiredby only adds to the requiredby list, it doesn't reset it itself. But in my opinion, it should do it. Anyway, I refactored this function in a public alpm_pkg_compute_requiredby(pkg) which returns the list of requiredby. And for checkdeps, I just exported it to alpm_checkdeps, without modification. Compared to my implementation using hash table, it now has the same functionality (detects missing dependencies, missing or extra requiredby), the code is much shorter (189 vs 299 lines), but it's also much more inefficient (1.3s vs 0.3s). Anyway, alpm doesn't contain hash table, so it's not like I have the choice :)