Skip to content

Commit 5a4a8b4

Browse files
committed
Fix performance issue with port sync
1 parent 86276a3 commit 5a4a8b4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseNodeView.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,23 @@ void SyncPortOrder(IEnumerable< NodePort > ports, IEnumerable< PortView > portVi
918918
var portViewList = portViews.ToList();
919919
var portsList = ports.ToList();
920920

921+
// If there is one port, we don't need to reorder it
922+
if (portsList.Count <= 1)
923+
return;
924+
925+
if (portViewList.Count == portsList.Count)
926+
{
927+
bool needReorder = false;
928+
929+
// Check if we need to re-order the ports:
930+
for (int i = 0; i < portsList.Count; i++)
931+
if (portsList[i].portData.identifier != portViewList[i].portData.identifier)
932+
needReorder = true;
933+
934+
if (!needReorder)
935+
return;
936+
}
937+
921938
// Re-order the port views to match the ports order in case a custom behavior re-ordered the ports
922939
for (int i = 0; i < portsList.Count; i++)
923940
{

0 commit comments

Comments
 (0)