From f08d8647274fc2c582005f9f0baebc114b2829cd Mon Sep 17 00:00:00 2001 From: Nagy Gabor <ngaba@bibl.u-szeged.hu> Date: Fri, 2 May 2008 00:32:45 +0200 Subject: [PATCH] One liner _alpm_pkg_find This patch kills some code duplication. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> --- lib/libalpm/package.c | 16 +--------------- 1 files changed, 1 insertions(+), 15 deletions(-) diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index ab49492..313c84a 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -1095,22 +1095,8 @@ error: */ pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle) { - alpm_list_t *lp; - ALPM_LOG_FUNC; - - if(needle == NULL || haystack == NULL) { - return(NULL); - } - - for(lp = haystack; lp; lp = lp->next) { - pmpkg_t *info = lp->data; - - if(info && strcmp(alpm_pkg_get_name(info), needle) == 0) { - return(info); - } - } - return(NULL); + return(alpm_list_find(haystack, needle, _alpm_pkgname_pkg_cmp)); } /** Test if a package should be ignored. -- 1.5.3.8