do not rely on name hashes for matching

6cfc4757b9 was overzealous in attempting
to optimize away a call to strcmp based on a comparison of hashes.  The
call can be skipped if the hashes are different, but different strings
could have the same hash.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2017-12-20 23:22:36 -05:00 committed by Allan McRae
parent 8bf972824a
commit 3a9a510ca8

View file

@ -698,10 +698,8 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
} }
for(j = _alpm_db_get_pkgcache(db); j; j = j->next) { for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
alpm_pkg_t *pkg = j->data; alpm_pkg_t *pkg = j->data;
/* with hash != hash, we can even skip the strcmp() as we know they can't if((pkg->name_hash != dep->name_hash || strcmp(pkg->name, dep->name) != 0)
* possibly be the same string */ && _alpm_depcmp(pkg, dep) && !alpm_pkg_find(excluding, pkg->name)) {
if(pkg->name_hash != dep->name_hash && _alpm_depcmp(pkg, dep)
&& !alpm_pkg_find(excluding, pkg->name)) {
if(alpm_pkg_should_ignore(handle, pkg)) { if(alpm_pkg_should_ignore(handle, pkg)) {
alpm_question_install_ignorepkg_t question = { alpm_question_install_ignorepkg_t question = {
.type = ALPM_QUESTION_INSTALL_IGNOREPKG, .type = ALPM_QUESTION_INSTALL_IGNOREPKG,