From 8e3e78c1164af5135425ae2a0af4e70aec8ff082 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 22 Sep 2023 15:08:16 -0600 Subject: [PATCH] temporal: optimize common case for ::get_tempo_and_meter() --- libs/temporal/temporal/tempo.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 5d2a7a5918..1124e69ae5 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -1092,6 +1092,7 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible will all be the non-const versions of these methods. */ + if (_tempos.size() == 1 && _meters.size() == 1) { t = &_tempos.front(); m = &_meters.front(); return _points.end(); } return _get_tempo_and_meter > (t, m, &Point::sclock, sc, _points.begin(), _points.end(), &_tempos.front(), &_meters.front(), can_match, ret_iterator_after_not_at); } @@ -1100,9 +1101,11 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible */ Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, superclock_t sc, bool can_match, bool ret_iterator_after_not_at) const { + if (_tempos.size() == 1 && _meters.size() == 1) { t = &_tempos.front(); m = &_meters.front(); return _points.end(); } return _get_tempo_and_meter > (t, m, &Point::sclock, sc, _points.begin(), _points.end(), &_tempos.front(), &_meters.front(), can_match, ret_iterator_after_not_at); } Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, Beats const & b, bool can_match, bool ret_iterator_after_not_at) const { + if (_tempos.size() == 1 && _meters.size() == 1) { t = &_tempos.front(); m = &_meters.front(); return _points.end(); } return _get_tempo_and_meter > (t, m, &Point::beats, b, _points.begin(), _points.end(), &_tempos.front(), &_meters.front(), can_match, ret_iterator_after_not_at); } Points::const_iterator get_tempo_and_meter (TempoPoint const *& t, MeterPoint const *& m, timepos_t const & pos, bool can_match, bool ret_iterator_after_not_at) const {