From 9897074fcc3d00741a496f6a5819fc49f33bcf0b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 1 Jul 2025 13:50:22 +0200 Subject: [PATCH] Micro-optimization: speed up connection-matrix rendering Bundle::type_channel_to_overall() takes a mutex and iterates over all ports. With a large number of channels in a bundle this. This reduces complexity from O(2N^2) to O(N^2) --- gtk2_ardour/port_matrix_grid.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/port_matrix_grid.cc b/gtk2_ardour/port_matrix_grid.cc index 861794cc24..e48efb7713 100644 --- a/gtk2_ardour/port_matrix_grid.cc +++ b/gtk2_ardour/port_matrix_grid.cc @@ -186,17 +186,16 @@ PortMatrixGrid::render (cairo_t* cr) x = bx; for (uint32_t k = 0; k < _matrix->count_of_our_type ((*i)->bundle->nchannels()); ++k) { + ARDOUR::BundleChannel c[2]; + + c[_matrix->column_index()] = ARDOUR::BundleChannel ( + (*i)->bundle, + (*i)->bundle->type_channel_to_overall (_matrix->type (), k) + ); y = by; for (uint32_t l = 0; l < _matrix->count_of_our_type ((*j)->bundle->nchannels()); ++l) { - ARDOUR::BundleChannel c[2]; - - c[_matrix->column_index()] = ARDOUR::BundleChannel ( - (*i)->bundle, - (*i)->bundle->type_channel_to_overall (_matrix->type (), k) - ); - c[_matrix->row_index()] = ARDOUR::BundleChannel ( (*j)->bundle, (*j)->bundle->type_channel_to_overall (_matrix->type (), l)