From 2a200bdc0ead3d2a2a0481db44b0bc080529aa69 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 3 Jan 2012 18:43:58 +0000 Subject: return two iterators into the Bars|Beats list of the tempo map rather than making a copy; use iterators in the GUI git-svn-id: svn://localhost/ardour2/branches/3.0@11146 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/tempo.h | 4 +++- libs/ardour/session_click.cc | 9 +++++---- libs/ardour/tempo.cc | 15 +++++---------- 3 files changed, 13 insertions(+), 15 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 8b1cfe6909..ff21d880f2 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -227,7 +227,9 @@ class TempoMap : public PBD::StatefulDestructible } const BBTPointList& map() const { return _map ; } - void map (BBTPointList&, framepos_t start, framepos_t end); + + void map (BBTPointList::const_iterator&, BBTPointList::const_iterator&, + framepos_t start, framepos_t end); void bbt_time (framepos_t when, Timecode::BBT_Time&); framecnt_t frame_time (const Timecode::BBT_Time&); diff --git a/libs/ardour/session_click.cc b/libs/ardour/session_click.cc index 86a5d4ad78..083f8055f9 100644 --- a/libs/ardour/session_click.cc +++ b/libs/ardour/session_click.cc @@ -41,7 +41,8 @@ Pool Click::pool ("click", sizeof (Click), 128); void Session::click (framepos_t start, framecnt_t nframes) { - TempoMap::BBTPointList points; + TempoMap::BBTPointList::const_iterator points_begin; + TempoMap::BBTPointList::const_iterator points_end; Sample *buf; if (_click_io == 0) { @@ -59,13 +60,13 @@ Session::click (framepos_t start, framecnt_t nframes) BufferSet& bufs = get_scratch_buffers(ChanCount(DataType::AUDIO, 1)); buf = bufs.get_audio(0).data(); - _tempo_map->map (points, start, end); + _tempo_map->map (points_begin, points_end, start, end); - if (points.empty()) { + if (distance (points_begin, points_end) == 0) { goto run_clicks; } - for (TempoMap::BBTPointList::iterator i = points.begin(); i != points.end(); ++i) { + for (TempoMap::BBTPointList::const_iterator i = points_begin; i != points_end; ++i) { switch ((*i).type) { case TempoMap::Beat: if (click_emphasis_data == 0 || (click_emphasis_data && (*i).beat != 1)) { diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 457e324c73..0dd5634f95 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1409,21 +1409,16 @@ TempoMap::round_to_type (framepos_t frame, int dir, BBTPointType type) } void -TempoMap::map (TempoMap::BBTPointList& points, framepos_t lower, framepos_t upper) +TempoMap::map (TempoMap::BBTPointList::const_iterator& begin, + TempoMap::BBTPointList::const_iterator& end, + framepos_t lower, framepos_t upper) { if (_map.empty() || upper >= _map.back().frame) { recompute_map (false, upper); } - for (BBTPointList::const_iterator i = _map.begin(); i != _map.end(); ++i) { - if ((*i).frame < lower) { - continue; - } - if ((*i).frame >= upper) { - break; - } - points.push_back (*i); - } + begin = lower_bound (_map.begin(), _map.end(), lower); + end = upper_bound (_map.begin(), _map.end(), upper); } const TempoSection& -- cgit v1.2.3