Recast: improve performance of dtDisjointSet::setUnion

Don't index multiple times into the same array with the same index.
This commit is contained in:
Kawe Mazidjatari 2024-07-08 16:03:04 +02:00
parent e28ea6cab1
commit 5ab83f2db4

View File

@ -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;
}
}