diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 8889ca39af..9a1d497567 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -301,6 +301,7 @@ public: timepos_t first_mark_after (timepos_t const &, bool include_special_ranges = false); Location* next_section (Location*, timepos_t&, timepos_t&) const; + Location* next_section_iter (Location*, timepos_t&, timepos_t&, std::vector& cache) const; Location* section_at (timepos_t const&, timepos_t&, timepos_t&) const; void marks_either_side (timepos_t const &, timepos_t &, timepos_t &) const; diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index d0cb25800d..c10fc816a0 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -1597,8 +1597,18 @@ Locations::sorted_section_locations (vector& locs) const Location* Locations::next_section (Location* l, timepos_t& start, timepos_t& end) const { - vector locs; - sorted_section_locations (locs); + std::vector locs; + return next_section_iter (l, start, end, locs); +} + +Location* +Locations::next_section_iter (Location* l, timepos_t& start, timepos_t& end, vector& locs) const +{ + if (!l) { + /* build cache */ + locs.clear (); + sorted_section_locations (locs); + } if (locs.size () < 2) { return NULL;