Dive site: compare pointers in MultiFilterSortModel::showDive()

To test whether to show a dive, the UUIDs of the filtered-by
location and the dive-site of a dive were compared. Since UUIDs
are unique (as the name implies), directly compare pointers.
Note: this code comes from a time when the filtered-by location
was not a pointer, but a copy.

Moreover, the if tested first for the same name, then (logical-or)
for the same uuid. This makes no sense, as the same dive-site
implies the same name. This code likewise can be explained by
historic reasons: the filtered-by location may have contained
a different name. Swap the order of the conditions: first test
for the same object and only of the objects differ, test for
the same same.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-10-27 15:18:29 +02:00 committed by Dirk Hohndel
parent 724055f0af
commit e8b3fdb4a6

View file

@ -592,7 +592,7 @@ bool MultiFilterSortModel::showDive(const struct dive *d) const
dive_site *ds = d->dive_site;
if (!ds)
return false;
return same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid;
return ds == curr_dive_site || same_string(ds->name, curr_dive_site->name);
}
if (models.isEmpty())