From 4484981d911a47ea250c61152a4cc1f32076f65b Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue, 24 Aug 2021 10:01:11 -0700 Subject: [PATCH] node: use binary search when looking for keyframes Minor optimization --- app/node/node.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/app/node/node.cpp b/app/node/node.cpp index d4296402c..e83b1f71f 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -551,11 +551,7 @@ SplitValue Node::GetSplitValueAtTime(const QString &input, const rational &time, int nb_tracks = GetNumberOfKeyframeTracks(input); for (int i=0;itime() <= time && next_key->time() > time) { + before = mid_key; + after = next_key; + break; + } else if (mid_key->time() < time) { + low = mid + 1; + } else { + high = mid - 1; + } + } + + if (before) { if (before->time() == time || ((!NodeValue::type_can_be_interpolated(type) || before->type() == NodeKeyframe::kHold) && after->time() > time)) { @@ -649,6 +662,8 @@ QVariant Node::GetSplitValueAtTimeOnTrack(const QString &input, const rational & return interpolated; } } + } else { + qWarning() << "Binary search for keyframes failed"; } }