From 5fa7d481c1c5ee7a018fb386659ea7079b3ab521 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 5 May 2022 17:07:15 +0200 Subject: [PATCH] Optimize Route::direct_feeds_according_to_reality Consolidate duplicate function calls, cache result in local variable. --- libs/ardour/io.cc | 8 ++++---- libs/ardour/route.cc | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 2de3c34366..50bc9079de 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -1624,10 +1624,10 @@ IO::connected_to (boost::shared_ptr other) const for (i = 0; i < no; ++i) { for (j = 0; j < ni; ++j) { - if ((NULL != nth(i).get()) && (NULL != other->nth(j).get())) { - if (nth(i)->connected_to (other->nth(j)->name())) { - return true; - } + boost::shared_ptr pa (nth(i)); + boost::shared_ptr pb (other->nth(j)); + if (pa && pb && pa->connected_to (pb->name())) { + return true; } } } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 8ae1abbd19..cabffb8eba 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3580,8 +3580,10 @@ Route::direct_feeds_according_to_reality (boost::shared_ptr node, boo boost::shared_ptr other (boost::dynamic_pointer_cast (node)); assert (other); + IOVector const& other_inputs (other->all_inputs()); + DEBUG_TRACE (DEBUG::Graph, string_compose ("Feeds from %1 (-> %2)?\n", _name, other->name())); - if (other->all_inputs().fed_by (_output)) { + if (other_inputs.fed_by (_output)) { DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdirect FEEDS to %1\n", other->name())); if (via_send_only) { *via_send_only = false; @@ -3608,7 +3610,7 @@ Route::direct_feeds_according_to_reality (boost::shared_ptr node, boo DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed its own return (%2)\n", iop->name(), other->name())); continue; } - if ((iop_out && other->all_inputs().fed_by (iop_out)) || iop->feeds (other)) { + if (iop->feeds (other) || (iop_out && other_inputs.fed_by (iop_out))) { DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed %2\n", iop->name(), other->name())); if (via_send_only) { *via_send_only = true;