summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-10 12:50:58 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-11 08:35:20 -0700
commitc9b8584bd2b7559008e57daf4359c02bad94d262 (patch)
tree14f58ccf3324712b316d652418e21cfbc0e333cf /core
parent215e5a45447f53047bfcc167da46714bf1496e8f (diff)
downloadsubsurface-c9b8584bd2b7559008e57daf4359c02bad94d262.tar.gz
core: sort device-table by id/model instead of model/id
The device table is accessed by core via a callback using call_for_each_dc(). This sorts the table by device-id. It is unclear whether this is needed - since currently all it does is make sure that the devices have a fixed order in XML and git log files. In any case, this means that the table had to be copied and sorted in call_for_each_dc(). Since the frontend now does its own sorting, we can just keep the core table sorted as it needs it. This in turn will ultimately make it possible to replace the callback by a simple loop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/device.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/core/device.cpp b/core/device.cpp
index b2e1d1d13..b4c78abe5 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -210,7 +210,7 @@ bool device::operator!=(const device &a) const
bool device::operator<(const device &a) const
{
- return std::tie(model, deviceId) < std::tie(a.model, a.deviceId);
+ return std::tie(deviceId, model) < std::tie(a.deviceId, a.model);
}
static const device *getDCExact(const QVector<device> &dcs, const divecomputer *dc)
@@ -291,17 +291,10 @@ extern "C" void clear_device_nodes()
device_table.devices.clear();
}
-static bool compareDCById(const device &a, const device &b)
-{
- return a.deviceId < b.deviceId;
-}
-
extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *, uint32_t, const char *, const char *, const char *),
bool select_only)
{
- QVector<device> values = device_table.devices;
- std::sort(values.begin(), values.end(), compareDCById);
- for (const device &node : values) {
+ for (const device &node : device_table.devices) {
bool found = false;
if (select_only) {
for (dive *d: getDiveSelection()) {