diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-04-14 15:21:00 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-15 10:24:31 +1200 |
commit | 5729f93e1f512aa9e68b0e01743152aaee2b7c12 (patch) | |
tree | 8fb8486b1fc5e698353b6065ff4124e9ccd45687 /desktop-widgets/command_divelist.h | |
parent | 1bc977452dc7824ebb86df1c1ba5e14cd0ff83b7 (diff) | |
download | subsurface-5729f93e1f512aa9e68b0e01743152aaee2b7c12.tar.gz |
Undo: don't store insertion index in undo command
When adding dives in an undo command, the index is saved in the
command. This seemed logical at first, because why calculate the
index more than once? But actually it made the code rather subtle
and brittle when multiple dives were added.
Moreover, this is a pointless optimization, as it doesn't optimize
the common case (only one execution).
Remove this for now and calculate the index on every execution. If
it ever turns out to be a bottle neck, it will be much more effective
to turn the linear search of the index into a binary search. A
further sensible optimization would be inserting in batches.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_divelist.h')
-rw-r--r-- | desktop-widgets/command_divelist.h | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/desktop-widgets/command_divelist.h b/desktop-widgets/command_divelist.h index f8d1ba180..2d3ee8db1 100644 --- a/desktop-widgets/command_divelist.h +++ b/desktop-widgets/command_divelist.h @@ -16,7 +16,6 @@ struct DiveToAdd { OwningDivePtr dive; // Dive to add dive_trip *trip; // Trip the dive belongs to, may be null dive_site *site; // Site the dive is associated with, may be null - int idx; // Position in divelist }; // Multiple trips, dives and dive sites that have to be added for a command |