From 5ab83f2db4a6d7010554e0a06f67b43fe179ad08 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:03:04 +0200 Subject: [PATCH] Recast: improve performance of dtDisjointSet::setUnion Don't index multiple times into the same array with the same index. --- .../recast/Detour/Include/DetourNavMeshBuilder.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h b/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h index eb1f5c65..cf243654 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h @@ -153,14 +153,17 @@ public: if (sx == sy) // Same set already. return; - if (rank[sx] < rank[sy]) + int& rankSx = rank[sx]; + int& rankSy = rank[sy]; + + if (rankSx < rankSy) parent[sx] = sy; - else if (rank[sx] > rank[sy]) + else if (rankSx > rankSy) parent[sy] = sx; else { parent[sy] = sx; - rank[sx] += 1; + rankSx += 1; } }