Performance: Move selectedUiItems outside the for loop

When number of objects is quite large, this causes a huge performance penalty.
This commit is contained in:
Magne Sjaastad committed 2023-10-13 16:31:14 +02:00
1 parent f1823da6d7
commit bd0ef7f63b
1 file changed
+5 -3
@@ -591,6 +591,11 @@ bool PdmUiTreeViewEditor::updateSelectionManager()
void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& subRootIndex /* = QModelIndex() */ )
{
auto allIndices = m_treeViewModel->allIndicesRecursive( subRootIndex );
if ( allIndices.empty() ) return;
std::vector<PdmUiItem*> selection;
selectedUiItems( selection );
for ( QModelIndex& index : allIndices )
{
QModelIndex filterIndex = m_filterModel->mapFromSource( index );
@@ -609,9 +614,6 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& subRo
PdmFieldReorderCapability* reorderability =
PdmFieldReorderCapability::reorderCapabilityOfParentContainer( pdmObject );
std::vector<PdmUiItem*> selection;
selectedUiItems( selection );
if ( reorderability && filterIndex.row() >= 0 && selection.size() == 1u && selection.front() == uiItem )
{
size_t indexInParentField = reorderability->indexOf( pdmObject );