From 2ee90ddae23dd86c68223c0d6c49f0b92d62429d Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 6 Nov 2007 00:55:45 -0600 Subject: Maintain list tail pointers in the head node List head nodes contain null 'prev' pointer, which we can (ab)use to maintain a back reference to the tail pointer of the list. While list additions are not _significantly_ improved, they are still sped up. Original $ time pacman -Qo /usr/bin/wtpt /usr/bin/wtpt is owned by lcms 1.17-2 real 0m3.623s user 0m1.883s sys 0m1.473s New $ time pacman -Qo /usr/bin/wtpt /usr/bin/wtpt is owned by lcms 1.17-2 real 0m2.006s user 0m0.263s sys 0m1.627s Signed-off-by: Aaron Griffin --- lib/libalpm/remove.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/remove.c') diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 6bbb4655..a4c3c15c 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -304,7 +304,8 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db) _alpm_log(PM_LOG_DEBUG, "removing %d files\n", filenum); /* iterate through the list backwards, unlinking files */ - for(lp = alpm_list_last(files); lp; lp = lp->prev) { + files = alpm_list_reverse(files); + for(lp = files; lp; lp = alpm_list_next(lp)) { unlink_file(info, lp, trans); /* update progress bar after each file */ -- cgit v1.2.3-54-g00ecf