From b2a57108c37f50408205566a2151d44350ab6ed3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 15 Jul 2023 11:08:25 -0600 Subject: [PATCH] actually reserve space for click grid points, to void RT memory allocation --- libs/ardour/session_click.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/ardour/session_click.cc b/libs/ardour/session_click.cc index dd38b4ec75..bf90e1576e 100644 --- a/libs/ardour/session_click.cc +++ b/libs/ardour/session_click.cc @@ -124,6 +124,7 @@ Session::click (samplepos_t cycle_start, samplecnt_t nframes) const samplepos_t end = start + move; _click_points.clear (); + assert (_click_points.capacity() > 0); TempoMap::use()->get_grid_with_iterator (_click_iterator, _click_points, samples_to_superclock (start, sample_rate()), samples_to_superclock (end, sample_rate())); if (_click_points.empty()) { @@ -310,6 +311,12 @@ Session::setup_click_sounds (Sample** data, Sample const * default_data, samplec delete[] tmp; sf_close (sndfile); } + + /* Overwhelmingly likely that we will have zero or 1 click grid point + * per cycle. So this is really overkill. If it is too low, it just + * causes RT memory allocation inside TempoMap::get_grid_with_iterator(). + */ + _click_points.reserve (16); } void