From 7c56b9b2fc56d9608d2bde99a59e72b980ef2bca Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 2 Dec 2020 23:21:15 -0700 Subject: [PATCH] Temporal: fix insanely incorrect implementation of timepos_t::distance() --- libs/temporal/timeline.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libs/temporal/timeline.cc b/libs/temporal/timeline.cc index f9723c87d0..841be465af 100644 --- a/libs/temporal/timeline.cc +++ b/libs/temporal/timeline.cc @@ -523,13 +523,13 @@ timepos_t::distance (Beats const & b) const } timecnt_t -timepos_t::distance (timepos_t const & d) const +timepos_t::distance (timepos_t const & other) const { - if (d.is_beats()) { - return distance (d._beats()); + if (time_domain() == other.time_domain()) { + return timecnt_t (int62_t (is_beats(), other.val() - val()), *this); } - return expensive_distance (d); + return expensive_distance (other); } timecnt_t @@ -540,12 +540,12 @@ timepos_t::expensive_distance (Temporal::Beats const & b) const timecnt_t -timepos_t::expensive_distance (timepos_t const & p) const +timepos_t::expensive_distance (timepos_t const & other) const { if (is_beats()) { - return timecnt_t (beats() + p.beats(), *this); + return timecnt_t (other.beats() - beats(), *this); } - return timecnt_t::from_superclock (superclocks() + p.superclocks(), *this); + return timecnt_t::from_superclock (other.superclocks() - superclocks(), *this); } /* */