From 996f85771a4d5a933b6bcdc31f64413444a6f79f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 21 May 2022 20:57:15 +0200 Subject: [PATCH] selection: remove select_dive() and deselect_dive() functions These were not optimal, because they would recalculate the current dive and divecomputers for every invocation. Signed-off-by: Berthold Stoeger --- core/selection.cpp | 43 ------------------------------------------- core/selection.h | 2 -- 2 files changed, 45 deletions(-) diff --git a/core/selection.cpp b/core/selection.cpp index 840965127..c4a7a0fe9 100644 --- a/core/selection.cpp +++ b/core/selection.cpp @@ -24,49 +24,6 @@ static void fixup_current_dc() dc_number = std::min(dc_number, number_of_computers(current_dive) - 1); } -extern "C" void select_dive(struct dive *dive) -{ - if (!dive) - return; - if (!dive->selected) { - dive->selected = 1; - amount_selected++; - } - current_dive = dive; - fixup_current_dc(); -} - -extern "C" void deselect_dive(struct dive *dive) -{ - int idx; - if (dive && dive->selected) { - dive->selected = 0; - if (amount_selected) - amount_selected--; - if (current_dive == dive && amount_selected > 0) { - /* pick a different dive as selected */ - int selected_dive = idx = get_divenr(dive); - while (--selected_dive >= 0) { - dive = get_dive(selected_dive); - if (dive && dive->selected) { - current_dive = dive; - return; - } - } - selected_dive = idx; - while (++selected_dive < divelog.dives->nr) { - dive = get_dive(selected_dive); - if (dive && dive->selected) { - current_dive = dive; - return; - } - } - } - current_dive = NULL; - } - fixup_current_dc(); -} - extern "C" struct dive *first_selected_dive() { int idx; diff --git a/core/selection.h b/core/selection.h index f1c70dc9b..dd83f6655 100644 --- a/core/selection.h +++ b/core/selection.h @@ -16,8 +16,6 @@ extern struct dive *current_dive; extern "C" { #endif -extern void select_dive(struct dive *dive); -extern void deselect_dive(struct dive *dive); extern struct dive *first_selected_dive(void); extern struct dive *last_selected_dive(void); extern bool consecutive_selected(void);