summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-09-14 17:09:42 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-03 10:53:26 -0700
commitce7e74f62f378eae9cc473db76b10a748f5607b4 (patch)
tree60d796cf17bf19d7729d023b2dedb0f5463513ec
parent2b557f567a33bb837fe32d611e7929cf2a4c92b2 (diff)
downloadsubsurface-ce7e74f62f378eae9cc473db76b10a748f5607b4.tar.gz
cleanup: pass divecomputer to getDC() and getDCExact() helpers
These are used to search for device nodes and were passed model and device id (for the exact version). However, all callers used them to search for the node corresponding to a specific struct divecomputer, so let's just pass that instead to make the caller site less complex. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/device.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/device.cpp b/core/device.cpp
index adbaff644..b6af22074 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -240,16 +240,16 @@ bool DiveComputerNode::operator<(const DiveComputerNode &a) const
return std::tie(model, deviceId) < std::tie(a.model, a.deviceId);
}
-static const DiveComputerNode *getDCExact(const QVector<DiveComputerNode> &dcs, const QString &m, uint32_t d)
+static const DiveComputerNode *getDCExact(const QVector<DiveComputerNode> &dcs, const divecomputer *dc)
{
- auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode{m, d, {}, {}, {}});
- return it != dcs.end() && it->model == m && it->deviceId == d ? &*it : NULL;
+ auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode{dc->model, dc->deviceid, {}, {}, {}});
+ return it != dcs.end() && it->model == dc->model && it->deviceId == dc->deviceid ? &*it : NULL;
}
-static const DiveComputerNode *getDC(const QVector<DiveComputerNode> &dcs, const QString &m)
+static const DiveComputerNode *getDC(const QVector<DiveComputerNode> &dcs, const divecomputer *dc)
{
- auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode{m, 0, {}, {}, {}});
- return it != dcs.end() && it->model == m ? &*it : NULL;
+ auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode{dc->model, 0, {}, {}, {}});
+ return it != dcs.end() && it->model == dc->model ? &*it : NULL;
}
void DiveComputerNode::showchanges(const QString &n, const QString &s, const QString &f) const
@@ -345,9 +345,9 @@ extern "C" void set_dc_nickname(struct dive *dive)
for_each_dc (dive, dc) {
if (!empty_string(dc->model) && dc->deviceid &&
- !getDCExact(dcList.dcs, dc->model, dc->deviceid)) {
+ !getDCExact(dcList.dcs, dc)) {
// we don't have this one, yet
- const DiveComputerNode *existNode = getDC(dcList.dcs, dc->model);
+ const DiveComputerNode *existNode = getDC(dcList.dcs, dc);
if (existNode) {
// we already have this model but a different deviceid
QString simpleNick(dc->model);
@@ -365,7 +365,7 @@ extern "C" void set_dc_nickname(struct dive *dive)
QString get_dc_nickname(const struct divecomputer *dc)
{
- const DiveComputerNode *existNode = getDCExact(dcList.dcs, dc->model, dc->deviceid);
+ const DiveComputerNode *existNode = getDCExact(dcList.dcs, dc);
if (existNode && !existNode->nickName.isEmpty())
return existNode->nickName;