diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-30 15:40:13 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-30 15:40:13 -0700 |
commit | 65f3135a92cb9bb33c9870105334ca458e1f151d (patch) | |
tree | 033889895ff6b40989e1070fdc59d5e9ec231aa5 | |
parent | b791b41db98ddec7b25448092fa30f24224af8c5 (diff) | |
download | subsurface-65f3135a92cb9bb33c9870105334ca458e1f151d.tar.gz |
Planner: don't do unnecessary work on empty dive plans
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | planner.c | 14 | ||||
-rw-r--r-- | planner.h | 1 | ||||
-rw-r--r-- | qt-ui/diveplanner.cpp | 4 |
3 files changed, 18 insertions, 1 deletions
@@ -49,6 +49,20 @@ void dump_plan(struct diveplan *diveplan) } #endif +bool diveplan_empty(struct diveplan *diveplan) +{ + struct divedatapoint *dp; + if (!diveplan || !diveplan->dp) + return true; + dp = diveplan->dp; + while(dp) { + if (dp->time) + return false; + dp = dp->next; + } + return true; +} + void set_last_stop(bool last_stop_6m) { if (last_stop_6m == true) @@ -13,6 +13,7 @@ extern void show_planned_dive(char **error_string_p); extern void set_last_stop(bool last_stop_6m); extern void get_gas_from_events(struct divecomputer *dc, int time, int *o2, int *he); extern int get_gasidx(struct dive *dive, int o2, int he); +extern bool diveplan_empty(struct diveplan *diveplan); extern struct dive *planned_dive; extern char *cache_data; diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 2b1662f7d..0d5b79edd 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -777,6 +777,8 @@ void DivePlannerPointsModel::addDecoToModel() { struct divedatapoint *dp; + if (diveplan_empty(&diveplan)) + return; bool oldRecalc = plannerModel->setRecalc(false); plannerModel->removeDeco(); @@ -832,7 +834,7 @@ void DivePlannerPointsModel::createTemporaryPlan() #if DEBUG_PLAN dump_plan(&diveplan); #endif - if (plannerModel->recalcQ()) { + if (plannerModel->recalcQ() && !diveplan_empty(&diveplan)) { plan(&diveplan, &cache, &tempDive, stagingDive, isPlanner()); addDecoToModel(); if (mode == ADD || mode == PLAN) { |