summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2017-02-26 18:19:50 +0100
committerPaul Davis <paul@linuxaudiosystems.com>2017-02-26 18:24:56 +0100
commit5456fd5717feb3133cc22aef80cc858d1cb0551b (patch)
tree056f426739f94d15c06007343fad7a35ad3e216a
parente653da32c06c00e2ff481f2fc9d2d2de34b5aba0 (diff)
make Selection::set (TrackViewList*) more efficient and emit less PI::Change signals
-rw-r--r--gtk2_ardour/selection.cc49
1 files changed, 16 insertions, 33 deletions
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc
index 23abfa17c3..ab26bfd48a 100644
--- a/gtk2_ardour/selection.cc
+++ b/gtk2_ardour/selection.cc
@@ -830,46 +830,29 @@ Selection::set (const TrackViewList& track_list)
{
clear_objects(); //enforce object/range exclusivity
- PresentationInfo::ChangeSuspender cs;
-
- if (!tracks.empty()) {
- /* cannot use set<T>::operator== (set<T> const &) here, because
- * apparently the ordering used within 2 sets is not
- * necessarily the same.
- */
-
- if (tracks.size() == track_list.size()) {
- bool missing = false;
-
- for (TrackViewList::const_iterator x = track_list.begin(); x != track_list.end(); ++x) {
- if (dynamic_cast<VCATimeAxisView*> (*x)) {
- continue;
- }
- if (find (tracks.begin(), tracks.end(), *x) == tracks.end()) {
- missing = true;
- }
- }
+ TrackViewList to_be_added;
+ TrackViewList to_be_removed;
- if (!missing) {
- /* already same selection: nothing to do */
- return;
- }
+ for (TrackViewList::const_iterator x = tracks.begin(); x != tracks.end(); ++x) {
+ if (find (track_list.begin(), track_list.end(), *x) == track_list.end()) {
+ to_be_removed.push_back (*x);
}
+ }
- /* argument is different from existing selection */
-
- for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) {
- if (dynamic_cast<VCATimeAxisView*> (*x)) {
- continue;
- }
- (*x)->set_selected (false);
+ for (TrackViewList::const_iterator x = track_list.begin(); x != track_list.end(); ++x) {
+ if (dynamic_cast<VCATimeAxisView*> (*x)) {
+ continue;
+ }
+ if (find (tracks.begin(), tracks.end(), *x) == tracks.end()) {
+ to_be_added.push_back (*x);
}
-
- tracks.clear ();
}
- add (track_list);
+ PresentationInfo::ChangeSuspender cs;
+ remove (to_be_removed);
+ add (to_be_added);
+
}
void