speed up load/quit for sessions containing ~25k events.
authornick_m <mainsbridge@gmail.com>
Fri, 23 Dec 2016 15:01:37 +0000 (02:01 +1100)
committernick_m <mainsbridge@gmail.com>
Fri, 23 Dec 2016 15:01:37 +0000 (02:01 +1100)
- MGR uses a _note_group to hold events.

- MRV & MGR delete canvas notes directly from their note group.

- sysex is untested (it uses MRV note group).

gtk2_ardour/ghostregion.cc
gtk2_ardour/ghostregion.h
gtk2_ardour/midi_region_view.cc

index e024a1a6e7ecc4e39ac3be4f0404336d76a90655..ba8ee05a4612a80d2d904953575999ed5283a988 100644 (file)
@@ -179,6 +179,7 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv,
                                  TimeAxisView& source_tv,
                                  double initial_unit_pos)
     : GhostRegion(rv, tv.ghost_group(), tv, source_tv, initial_unit_pos)
+    , _note_group (new ArdourCanvas::Container (group))
     , _optimization_iterator(events.end())
 {
        _outline = UIConfiguration::instance().color ("ghost track midi outline");
@@ -200,6 +201,7 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv,
                   msv.trackview(),
                   source_tv,
                   initial_unit_pos)
+    , _note_group (new ArdourCanvas::Container (group))
     , _optimization_iterator(events.end())
 {
        _outline = UIConfiguration::instance().color ("ghost track midi outline");
@@ -324,7 +326,7 @@ MidiGhostRegion::update_contents_height ()
 void
 MidiGhostRegion::add_note (NoteBase* n)
 {
-       GhostEvent* event = new GhostEvent (n, group);
+       GhostEvent* event = new GhostEvent (n, _note_group);
        events.insert (make_pair (n->note(), event));
 
        event->item->set_fill_color (UIConfiguration::instance().color_mod(n->base_color(), "ghost track midi fill"));
@@ -356,12 +358,9 @@ MidiGhostRegion::add_note (NoteBase* n)
 void
 MidiGhostRegion::clear_events()
 {
-       _optimization_iterator = events.begin();
-
-       while (_optimization_iterator != events.end()) {
-               delete (*_optimization_iterator).second;
-               _optimization_iterator = events.erase (_optimization_iterator);
-       }
+       _note_group->clear (true);
+       events.clear ();
+       _optimization_iterator = events.end();
 }
 
 /** Update the x positions of our representation of a parent's note.
index 377530e2ea5cbf6045dc0c2c9c86bf0c5c1f32a1..0259231551624b76919b80645936605f048203bb 100644 (file)
@@ -116,6 +116,7 @@ public:
        void clear_events();
 
 private:
+       ArdourCanvas::Container* _note_group;
        ArdourCanvas::Color _outline;
        ArdourCanvas::Rectangle* _tmp_rect;
        ArdourCanvas::Polygon* _tmp_poly;
index 1a2a255a298d1c19b577af9fa9925a303d0272af..4feacff3a427f131133ee6091bb54054f834ee95 100644 (file)
@@ -978,10 +978,8 @@ MidiRegionView::clear_events ()
                }
        }
 
-       for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
-               delete *i;
-       }
 
+       _note_group->clear (true);
        _events.clear();
        _patch_changes.clear();
        _sys_exes.clear();