summaryrefslogtreecommitdiffstats
path: root/core/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-05-28 21:25:44 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-29 08:57:04 -0700
commit76a38b63269f554f3299e8ddfb1ea335bbc932d5 (patch)
tree6d719f5c0f2b7b70fa6bc0021b483fa738ef0aba /core/libdivecomputer.c
parent88738ede30ce9c14d54758b45c48e492bd061ed4 (diff)
downloadsubsurface-76a38b63269f554f3299e8ddfb1ea335bbc932d5.tar.gz
More optimal search
The linear search to determine that a just downloaded dive was already downloaded, started from the oldest dive in the logbook. It is, however more likely that a just downloaded dive is one of the most recently downloaded. So, just search backwards. Just a trivial performance improvement. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'core/libdivecomputer.c')
-rw-r--r--core/libdivecomputer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index ec8b456f7..db4a7a434 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -481,7 +481,7 @@ static int find_dive(struct divecomputer *match)
{
int i;
- for (i = 0; i < dive_table.preexisting; i++) {
+ for (i = dive_table.preexisting - 1; i >= 0; i--) {
struct dive *old = dive_table.dives[i];
if (match_one_dive(match, old))