Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=e300e952004046ea0f6f9c05b07a8e8efa2640aa
commit e300e952004046ea0f6f9c05b07a8e8efa2640aa Author: Michel Hermier <herm...@frugalware.org> Date: Wed Oct 22 10:53:46 2014 +0200 libpacman: Simplify trans_t::syncpkgs.remove calls, no need to use slow _pacman_syncpkg_cmp, we allready got the pointer from the list (this path is still optimisable with iterators though). diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp index ff60957..98867be 100644 --- a/lib/libpacman/trans.cpp +++ b/lib/libpacman/trans.cpp @@ -200,14 +200,6 @@ int _pacman_trans_set_state(pmtrans_t *trans, int new_state) return(0); } -/* Helper functions for _pacman_list_remove - */ -static -int _pacman_syncpkg_cmp(const void *s1, const void *s2) -{ - return(strcmp(((pmsyncpkg_t *)s1)->pkg_name, ((pmsyncpkg_t *)s2)->pkg_name)); -} - static int check_olddelay(Handle *handle) { @@ -587,11 +579,8 @@ int __pmtrans_t::prepare(FPtrList **data) } if(rmpkg) { pmsyncpkg_t *rsync = find(rmpkg); - pmsyncpkg_t *spkg = NULL; - _pacman_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg); - syncpkgs.remove(rsync, _pacman_syncpkg_cmp, &spkg); - delete spkg; + syncpkgs.remove(rsync); continue; } } @@ -622,11 +611,8 @@ int __pmtrans_t::prepare(FPtrList **data) ps->m_replaces.add(q); if(rsync) { /* remove it from the target list */ - pmsyncpkg_t *spkg = NULL; - _pacman_log(PM_LOG_FLOW2, _("removing '%s' from target list"), miss->depend.name); - syncpkgs.remove(rsync, _pacman_syncpkg_cmp, &spkg); - delete spkg; + syncpkgs.remove(rsync); } } else { /* abort */ diff --git a/lib/libpacman/util/flist.h b/lib/libpacman/util/flist.h index 815e3a9..b028dbe 100644 --- a/lib/libpacman/util/flist.h +++ b/lib/libpacman/util/flist.h @@ -28,9 +28,6 @@ #include <stddef.h> -/* Sort comparison callback function declaration */ -typedef int (*_pacman_fn_cmp)(const void *, const void *); - #ifdef __cplusplus #include "util/falgorithm.h" @@ -878,27 +875,6 @@ public: return iterator(newItem); } - bool remove(void *ptr, _pacman_fn_cmp fn, value_type *data) - { - return remove(fn, ptr, data); - } - - bool remove(_pacman_fn_cmp fn, void *ptr, value_type *data = nullptr) - { - for(auto i = c_first(), end = c_end(); i != end; i = i->next()) { - if(fn(ptr, i->m_data) == 0) { - /* we found a matching item */ - i->remove(); - if(data != nullptr) { - *data = i->m_data; - } - delete i; - return true; - } - } - return false; - } - void swap(FList &o) { FCListItem::swap(o); } _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git