index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2010-12-14 12:36:02 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-12-14 12:36:02 -0600 |
commit | 919bb6c9e00820c3930067b5985a246a455bef57 (patch) | |
tree | aff800a6e65184a873c02bcb908196b0022047c5 /lib/libalpm/package.c | |
parent | c2a73ba989fffb59c1b8ac7edb265a996dfc184d (diff) |
-rw-r--r-- | lib/libalpm/package.c | 15 |
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 5b479b4f..2ea51251 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -552,6 +552,7 @@ int _alpm_pkg_cmp(const void *p1, const void *p2) pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle) { alpm_list_t *lp; + unsigned long needle_hash; ALPM_LOG_FUNC; @@ -559,11 +560,21 @@ pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle) return(NULL); } + needle_hash = _alpm_hash_sdbm(needle); + for(lp = haystack; lp; lp = lp->next) { pmpkg_t *info = lp->data; - if(info && strcmp(info->name, needle) == 0) { - return(info); + if(info) { + /* a zero hash will cause a fall-through just in case */ + if(info->name_hash && info->name_hash != needle_hash) { + continue; + } + + /* finally: we had hash match, verify string match */ + if(strcmp(info->name, needle) == 0) { + return(info); + } } } return(NULL); |